While rsync natively supports SSH protocol (as shown in the working example: rsync -avr -e ssh /home/dir user@example.com:/home/
), FTP protocol support requires additional tools and configuration. The fundamental issue is that rsync doesn't directly speak FTP protocol.
Here are three practical approaches to achieve rsync functionality over FTP:
Option 1: Using curlftpfs (FUSE-based solution)
# Mount remote FTP as local directory
sudo apt-get install curlftpfs
mkdir ~/ftp_mount
curlftpfs ftp://user:password@example.com ~/ftp_mount
# Now use rsync normally
rsync -av /home/dir/ ~/ftp_mount/remote/path/
# Unmount when done
fusermount -u ~/ftp_mount
Option 2: Using lftp (mirror command)
lftp -e "mirror -R /local/path /remote/path" ftp://user:password@example.com
Option 3: Using ncftp (alternative FTP client)
ncftpput -R -v -u user -p password example.com /remote/path /local/path/*
When dealing with FTP (which transmits credentials in clear text), consider these security enhancements:
- Use SFTP if the server supports it (different from FTPS)
- Configure vsftpd to use SSL/TLS if you control the server
- Use .netrc file for credentials with proper permissions (chmod 600)
For large transfers over FTP:
# Use tar piped to ftp for better performance with many small files
tar czf - /local/path | ftp -n example.com <
For modern systems, rclone provides excellent FTP support with rsync-like functionality:
rclone sync /local/path ftp_remote:path --progress
While rsync is commonly used with SSH for secure file transfers, many legacy systems still rely on FTP as their primary file transfer protocol. The standard rsync command:
rsync -avr -e ssh /home/dir user@example.com:/home/
won't work when your remote server only has FTP access. Let's explore practical solutions.
Rsync was designed to work with its own protocol or SSH because:
- FTP lacks the delta-transfer algorithm rsync uses
- FTP doesn't preserve file metadata well
- FTP connections are generally less secure
Option 1: Using curlftpfs
Mount the remote FTP location as a local filesystem:
sudo apt-get install curlftpfs
mkdir ~/ftp_mount
curlftpfs ftp://user:password@example.com ~/ftp_mount
rsync -avr /home/dir/ ~/ftp_mount/home/
fusermount -u ~/ftp_mount
Option 2: Using lftp
lftp has mirroring capabilities similar to rsync:
lftp -e "mirror -R /home/dir /remote/dir" ftp://user:password@example.com
Option 3: Using ncftp
ncftp offers recursive directory transfers:
ncftpput -R -v -u user -p password example.com /remote/dir /home/dir/*
When working with FTP:
- Consider using FTPS (FTP over SSL) if available
- Use .netrc files to store credentials securely
- Set appropriate file permissions (chmod 600)
For regular sync jobs, create a bash script:
#!/bin/bash
MOUNT_POINT=~/ftp_mount
REMOTE_PATH="ftp://user:password@example.com"
mkdir -p $MOUNT_POINT
curlftpfs $REMOTE_PATH $MOUNT_POINT
rsync -avr --delete /home/dir/ $MOUNT_POINT/home/
fusermount -u $MOUNT_POINT
- Compress files before transfer (-z option in some clients)
- Transfer during off-peak hours
- Consider batch processing large directories