My hosting company is great, with all of their dedicated servers even the low cost ones users get 100GB free of FTP backup space. Now at first I didn’t really see the point in this, not because backup’s aren’t important but because I like to use rsync for my backups, and it has no support for FTP connections.
However there is a neat trick you can do for FTP support in Rsync, it’s fairly simple really, you install some extra software that lets you mount an FTP service just as if it was a hard drive, usb pen or network share. Then your able to backup straight onto this mount without the worry about FTP support and using rsync.
So you need to first get this ftp mounting software installed.
apt-get install curlftpfs
Now create a folder somewhere on your machine, this is where the ftp server is going to be mounted, it’s posistion is completly upto you, this is just an example
mkdir /mnt/backup_server
The configuration for this is fairly simple and is done in the normal fstab file, which is great because you can then use the mount and unmount commands just like any other drive on your system.
#Open and edit your fstab nano -w /etc/fstab #At the end of the file enter the following (change to match your setup) #curlftpfs#user:pass@ip-address /local/directory fuse rw,allow_other,uid=user-id 0 0 curlftpfs#pingbin:1234@10.0.0.1 /mnt/backup_server fuse rw,allow_other,uid=1000 0 0 #Save and close the file, then mount your directory mount /mnt/backup_server
Cool, you should be ready to go, I would suggest doing the following just to ensure it’s working
#Go in the mounted directory, check nothings there. cd /mnt/backup_server ls -la #Create a file touch ./test.txt #Now FTP to the server like normal and check if it's there root@fr:/mnt/ftpbackup# ftp 10.0.0.1 Connected to ftpback 220-Welcome to Pure-FTPd. Name (ftpback): OK. Password required Password: ftp> ls 200 PORT command successful -rw-r--r-- 1 100 100 0 Jan 1 17:54 test.txt
As you can see it worked, so you should be a bit more confident that your backups are going to save correctly.
Finally I enter this into my crontab to backup daily, monthly and weekly
crontab -e 1 1 * * * rsync -asvz --no-owner --no-group /webserver /mnt/backup_server/daily 2 2 2 * * rsync -asvz --no-owner --no-group /webserver /mnt/backup_server/weekly 3 3 3 3 * rsync -asvz --no-owner --no-group /webserver /mnt/backup_server/monthly
4 comments On HowTo: Rsync to a Backup FTP server
Thanks for a good tutorial. This works well
Hi, thanks for your tutorial.
I tried to install it on my raspberry, but there is an error:
cd /mnt/ftp_backup/
-> works, I see the files of the remote server
rsync -avz –no-owner –no-group /home/pi/mysqldump/ /mnt/ftp_backup/
sending incremental file list
./
raspibackup-20140425.bz2 no problems, file is copied.
Any ideas? Thanks!
why uid=1000?
I’m root on my server where I alter fstab, Do I need to use uid=0 of root in my case?
Why do you use uid=1000?
In my server, I’m root, may I use uid=0?