How to use backup.sh to backup your databases and directorys

There is a backup script in astercc scripts directory, you can use it to make a sechduled backup mission for your databases and directorys.

First you should make a directory for backup , I make it to /home/backup.

Copy the bakcup.sh and backup.conf  to /home/backup

cp astercc/scripts/backup.sh astercc/scripts/backup.conf  /home/backup

Then, configure the backup.conf:

[local] #this name of server,just for mark; default is the hostname of this server
hostname=

#local path of save the backup file, default is back script running path
localpath=

#how many latest days backup file will be saved in local server
savelocal=3

#when run bakcup shell,it will sent a mail to notify if set the mailto
#the backup notify mail to
mailto=

#the backup notify mail from
mailfrom=

if you want to send the backup file to a remote server by ftp,  just configure the [ftp] segment
[ftp] #if set, will try to sent the backup file to the host by ftp
ftphost=
ftpuser=
ftppasswd=

#directory name to save the database backup file in ftp home
ftpdbpath=

#directory name to save the dir backup file in ftp home
ftpdirpath=

[dblist] #which database would be backup you want; format: databasename:user:password
#for astercc database
astercc:astercc:asterccsecret

[dirlist] #which directory would be backup you want, the absolute path of directory and the basename of directory: /etc/asterisk:asterisk

#for asterisk etc
/etc/asterisk:asterisk

then we execute the ./backup.sh to test, after execute the backup.sh, execut “find” in /home/backup, could get likes following content:

.
./backup.conf
./dir_backup
./dir_backup/localsave
./dir_backup/localsave/asterisk.2010-11-09-05.tar.gz
./backup.sh
./db_backup
./db_backup/localsave
./db_backup/localsave/astercc.2010-11-09-05.tar.gz
./db_backup/dbbk.log

If everything is ok ,  we should set a schedule backup mission with crontab.

execute “crontab -e” and add the following line :

0 0 * * * /home/backup/backup.sh >/dev/null 2>&1

it’s means that the /home/backup/backup.sh will execute  at 00:00:00 every days, you can adjust the execute time for fit your request.

Leave a Reply