To use the rsync
command to transfer files over FTP on Linux or Unix, you can use the ftp://
URL format and specify the FTP username and password as part of the URL.
Here's an example of how to use rsync
to transfer files from a local directory to an FTP server:
rsync -avz /local/directory/ ftp://username:password@ftp.server.com/remote/directory/
This command will transfer all files in the /local/directory/
directory to the /remote/directory/
directory on the FTP server. The -a
option tells rsync
to preserve file permissions and other attributes, and the -v
option enables verbose output. The -z
option enables compression to reduce the amount of data transferred.
You can also use rsync
to transfer files from an FTP server to a local directory by reversing the source and destination arguments. For example:
rsync -avz ftp://username:password@ftp.server.com/remote/directory/ /local/directory/
Keep in mind that the FTP password will be visible to other users on the system if they use a command like ps
to view the command line arguments of the rsync
process. To avoid this, you can use the --password-file
option to specify a file containing the FTP password.
rsync --password-file=/path/to/password/file -avz ftp://username@ftp.server.com/remote/directory/ /local/directory/
This will read the FTP password from the specified file, rather than passing it on the command line.