Simple FTP backup

The following script creates an archive of the entire server and uploads it to
a FTP server:

#!/bin/sh
NAME="backup"
ENDING="tar.gz"
DATE=`date +"%d-%m-%Y-%H-%M-%S"`
FULLNAME="$NAME-$DATE.$ENDING"

cd /
tar czfv $FULLNAME /

ftp -inv SERVERIP/DOMAINĀ << EOF

user username password
put $FULLNAME
bye 
EOF

rm -f $FULLNAME

You can add the script to crontab if you want to automatically execute it:

crontab -e

Add the following to execute the script every day at 12AM:

0 0 * * * sh /path/to/script/ftpbackup.sh

2 thoughts on “Simple FTP backup

Leave a Reply

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