Hi all,
I’d like to share a part of my workflow with regards to backing up my site on a daily basis. Here’s the script named “backupNameOfSite.sh” which you can create in the Mac Terminal (or in Putty if you’re on windows). I have also created a cronjob on the hosting server so the backup runs every morning at 3am. I receive an email after the backup is done. The backup results in two files: nameOfSite-backup-Year-Month-Day-Hour-Minute.tgz and nameOfSite-backup-Year-Month-Day-Hour-Minute.sql.
We use this technique also for syncing our staging server with the live server.
Give it a try - it works.
Regards, Leo
#!/bin/sh
source="nameOfSiteFolder"
date=<code>date '+%Y-%m-%d-%H-%M'</code>
filename="nameOfBackupFolder/nameOfSiteFolder/nameOfSite-backup-$date.tgz"
echo "Backup of files nameOfSite starting..."
tar cvpzf $filename $source
echo "File backup done"
echo "Create Dump of database..."
host="YourHostName(in doubt ask your hoster)"
db="databaseName"
user="user"
pw="password"
mysqldump --opt -u $user -h $host -p$pw $db > "nameOfBackupFolder/nameOfSiteFolder/nameOfSite-backup-$date.sql"
echo "Backup done"