Incremental FTP backups

Jul 13, 2015 13:50 · 87 words · 1 minute read

If you happen to only have FTP access to a server or account (CPanel) you’re looking after, LFTP is an efficient tool to keep incremental backups. This will make hard links of the previous backup and updated it, copying and storing only changed files.

#!/usr/bin/env bash
username='xxx'
password='xxx'
host='ftp.host'
localBackupDir='/backups/host'
remoteDir='/public_html/'
cd $localBackupDir
rm -rf backup.3
mv backup.2 backup.3
mv backup.1 backup.2
mv backup.0 backup.1
cp -al backup.1 backup.0 #-al or -r
lftp -e "set ssl:verify-certificate no; \
         mirror --only-newer --parallel=4 $remoteDir $localBackupDir/backup.0;\
         exit"\
     -u $username,$password $host