Make a directory called /home/[username]/backupmsaluste wrote:That Cron would be really helpful. Please post it here
(replace <username> with your username)
In this directory, create a file called backup.csh containing:
Code: Select all
# Go to the web root
cd ~/public_html
# Get the current time for the archive file name
setenv DATE `date | sed 's/ /_/g'`
# Dump out the database to a file in the web root
mysqldump --opt -u [username] -p'[password]' [database] > backup.$DATE.sql
# Tar up the current directory and place the file in ~/backup
tar cvzf ~/backup/backup.$DATE.tar.z .
# Remove the SQL file
rm -f backup.$DATE.sql
# Find all files in the backup directory older than 30 days and remove it
find ~/backup -name 'backup.*.tar.z' -mtime +30 -exec /bin/rm {} \;
The CRON:
Code: Select all
0 0 * * * cat /home/[username]/backup/backup.csh | tcsh
Once you test it manually, I would try to revive this data in a test install to make sure that this backup contains absolutely everything you need. You might want to clear out the cache first, or better yet, find a way to have the tar command ignore /tmp completely.