Linux site/mysql backup script with automation old files rotation
2009-12-27 16:05
Just small script that does automatickly backups of selected site including database. And makes automatickly backup rotation.
So small script that does all that. Do not foger replace "/home/www" and /misc folders and others variables <variable> with your own. Files are deleted older than 7 days.
#!/bin/sh echo Backup Started `date` # Paths baseDirBackup=/misc targetDir=/home/www # Mysql configuration usernameMysql=<username> passwordMysql=<password> databaseMysql=<database> dirBackup=$baseDirBackup/`date +%Y%m%d` mkdir $dirBackup tar czf $dirBackup/dump.tar.gz $targetDir mysqldump -u $usernameMysql --password=$passwordMysql --default-character-set=utf8 $databaseMysql > $baseDirBackup/`date +%Y%m%d`/dump_db.sql find $baseDirBackup -mtime +7 -delete echo Backup Completed `date`
After placing all that you can setup cronjob command to make backup every night.
Back »
Comments: 0
Leave a reply »