Simple FTP backup script

The first post for this year…

Simple FTP backup script

# nano backup_script

Add next lines and save.

DM=$(date +"%Y-%m-%d")
tar -Pzcf /backup/backup_$DM.tar.gz /backup/some_dir/
cd /backup
ftp -nv <<EOF
user ftp_username ftp_password
put backup_$DM.tar.gz
echo -e  "FTP backup done!"

Make it executable with

# chmod +x backup_script

Of course, you need to replate ftp_username and ftp_password with valid username and password. Also, IP address should be replaced with your ftp server IP address.

Add this script to cron (for example once per day at 4:00AM)

Leave a Reply

Your email address will not be published. Required fields are marked *