1

I know the ftp username, password, and directory of the source.

I just want to download the whole thing to a new server.

Simple download.

The username is not root. So I wonder how I would specify the directory name? Should I give the /home/username/public_html or should I give it as ~username/public_html

3
  • This is completely dependent on how the server is configured. Jan 10, 2013 at 9:40
  • I used cpanel. We got ftp server and stuff.
    – user4951
    Jan 10, 2013 at 15:35
  • all I want is to download a directory to my server
    – user4951
    Jan 10, 2013 at 15:37

2 Answers 2

2

wget

Use wget as follow

wget --mirror --no-parent --user=<ftpuser> --password=<ftppassword> ftp://server/<directory path>

It will download the whole directory recursively.

Option --no-parent

Do not ever ascend to the parent directory when retrieving recursively. This is a useful option, since it guarantees that only the files below a certain hierarchy will be downloaded.

So the following

wget --mirror --no-parent --user=<ftpuser> --password=<ftppassword> ftp://server/home/username/public_html

will only download directory structure starting with public_html.

Directory path

You should login ftp server once to confirm the path. Depending on how ftp server is configure, the path may actually start within the home directory. In that case, the directory path will be /public_html only.

Changing Directory Ownership

Change the user and group of the downloaded directory with following command

chown -R <user>:<group> public_html

If you want to change to user www-data and group www-data

chown -R www-data:www-data public_html

You may also want to remove write permission for others/anybody

chmod -R o-w public_html

-R = recursively

Category (can assign multiple without space)
u = user
g = group
o = others = anybody

Add/Remove
"-" sign = remove permission following the sign, from category before the sign
"+" sign = add permission following the sign, to category before the sign

Permission (can assign multiple without space)
r = read permission
w = write permission
x = execute permission

Example
ug+w = add write permission to user and group
ugo-wx = remove write and execute permission from user, group and others
2
  • who will own the downloaded file? root?
    – user4951
    Jan 11, 2013 at 1:58
  • Files will be owned by user downloading them. If you use root to download, then yes, root owns them. I added instruction to change ownership after download.
    – John Siu
    Jan 11, 2013 at 2:13
0
prompt
mget ~/public_html

This should download everything from /home/username/public_html directory.

4
  • what does prompt do?
    – user4951
    Jan 10, 2013 at 20:00
  • By default mget runs in interactive mode i.e it will ask you if it is fine to copy over xyz file/dir and you have to respond with either y or n. To turn this feature off, prompt command needs to be executed. It toggles the Interactive Mode of FTP client. Jan 10, 2013 at 20:16
  • will this be recursive?
    – user4951
    Jan 11, 2013 at 1:57
  • Yes, of course. Test it for yourself :) Jan 11, 2013 at 22:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.