You are on page 1of 3

SCRIPT > Automatically backup CCcam.cfg to a FTP s Script >Automatically backup CCcam.

cfg to a FTP server '' This script works on our Debian servers but you can make it work on other Linux / Unix systems also. It copy's the var/etc/ folder in to a compressed file including CCcam.cfg unless you store the file in a other location. Then it sends it to a FTP server and remove the compressed file from your server to keep things neatly. Requirments: Shell access Editor (Vi, Pico or Nano...) Cron ncftp (if not on your system install it [apt-get install ncftp] or use a other ftp program and edit the code)

Step1 Log on to your FTP server and create a folder named backup. Step 2 Log into your CCcam server as the user you want to run this script as (usually root). You can then create a file on your server. # cd /etc # mkdir backup # cd backup # nano backup.sh Step 3: Cut and paste the script below into the file and then edit the parts required. #!/bin/sh HOST='ftp-server-IP-or-hostname' USER='ftp-server-username' PASSWD='ftp-server-password' DATE=`/bin/date +%Y%m%d` TIME=`/bin/date +%H` HOSTNAME=`/bin/hostname` tar zcvf $DATE.$TIME.$HOSTNAME.tar.gz /var/etc > /dev/null && ncftpput -u $USER -p $PASSWD $HOST /backup $DATE.$TIME.

$HOSTNAME.tar.gz ;: rm `date +%Y%m%d`.`date +%H`.$HOSTNAME.tar.gz It is pretty straight forward, just edit the 3 variables to make it work for you. Replace ftp-server-IP-or-hostname by for example 84.85.86.87 or somename.com Replace ftp-server-username by the username you use to log on to the FTP server Replace ftp-server-password by the password you use to log on to the FTP server Step 4: After you have edited and save the file you must chmod the file 755 to make it executable. # chmod 755 /etc/backup/backup.sh Step 5: To run the backup script automatically you need to add a line to crontab. # crontab -e To run daily enter the line * 0 * * /etc/backup/backup.sh To run weekly on Sunday @00:00hr enter the line: 0 0 * * 0 /etc/backup/backup.sh To run monthly on the first day of the month @00:00hr enter the line: 0 0 1 * * /etc/backup/backup.sh Your done!

To check if the script is working: # cd / # etc/backup/backup.sh No errors must show. Now login to your FTP server and look for your backupfile in the folder /backup/

Please note that this script does not remove the old files from the FTP server! Hope this helps you restore your server after a crash or hardware failure. ''

You might also like