Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
#Define FTP USername and Pasword
#Define FTP Server
#Define how many files you want to keep
#Create zipfile with the contents you want to backup
zip -r /data/backup/ /data/svn/data
#Upload the zipfile with a timestamp in its name
DATE=`date +%Y-%m-%d_%H-%M-%S`
curl -T /data/backup/ ftp://$SERVER/backup-$ --user $USERPW
#Delete old backup files
#List all files from server | sort the names alphabetically | select all but the last x of them (the last are the newer files) | delete the selected files
curl -l ftp://$SERVER/ --user $USERPW | sort | head -n -$KEEPFILES | while read line ; do
curl ftp://$SERVER/ -Q "DELE $line" --user $USERPW

Simple FTP based backup of a zip file

This script creates a zipfile and uploads it to an FTP server. You can define how many backups should be stored on the server. Older files will be deleted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.