-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcron_backup_echo.txt
37 lines (27 loc) · 1.12 KB
/
cron_backup_echo.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/sh
#Set information specific to your site
siteroot="YOUR FULL SITE PATH"
db_host="YOUR DB HOST"
db_user="YOUR DB USERNAME"
db_password="YOUR DB PASSWORD"
db_name="YOUR DB NAME"
#Set the date and name for the backup files
date=`date '+%F-%H:%M'`
backupname="backup.$date.tar.gz"
#Dump the mysql database
echo $siteroot;
echo "Starting backup at:"; date
mysqldump --single-transaction -h $db_host -u $db_user --password="$db_password" $db_name > $siteroot/db_backup.sql
if [ ! -s $siteroot/db_backup.sql ]
then echo "The SQL backup failed! Exiting..." && exit 0
fi
echo "Database dump complete! Creating site contents backup at:"; date
#Backup Site
tar cpfP $siteroot/sitebackup.tar $siteroot/web/content/
if [ ! -s $siteroot/sitebackup.tar ]
then echo "Site contents backup failed! Exiting..." && exit 0
fi
echo "Contents compression complete! Compressing contents and database into single file at:"; date
#Compress DB and Site backup into one file
tar czpfP $siteroot/$backupname --exclude 'sitebackup' --remove-files $siteroot/sitebackup.tar $siteroot/db_backup.sql
echo "Full site backup complete at:"; date