-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanta-backup
executable file
·42 lines (26 loc) · 1.53 KB
/
manta-backup
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
37
38
39
#!/usr/bin/bash
# Process to backup wordpress to a manta object storage server
# Assumes you have a valid set of MANTA environment variables for this to work
export INSTANCE_SHORTNAME=`/usr/sbin/mdata-get sdc:uuid | cut -f 1 -d -`
# This generates a likely unique directory per instance you are running
# It exists so that if you do a restore of your data, the whole point of
# backups, and then the restored running instance takes a backup, it doesn't
# land on the original's backup directory.
export TIME=`date +%s_%Y_%m_%d`
cd /home/node/website
MYSQLDUMP=`which mysqldump`
if [ $? -ne 0 ]
then
echo "no mysqldump found. exiting";
exit 1;
fi;
mmkdir -p ~~/stor/backups/wordpress/$INSTANCE_SHORTNAME/
# Collect the haproxy configuration, put it in manta
tar -cz /root/.acme.sh/ /opt/local/etc/certs /opt/local/etc/haproxy.cfg | mput ~~/stor/backups/wordpress/${INSTANCE_SHORTNAME:?}/${TIME:?}.haproxy.config.tgz || exit 1;
# Dump the DB, put the dump in manta
$MYSQLDUMP -h localhost -u username --password=password wordpress --single-transaction --quick --lock-tables=false | gzip | mput ~~/stor/backups/wordpress/$INSTANCE_SHORTNAME/${TIME:?}.database.sql.gz || exit 1;
tar -cf - /home/node/website | gzip | mput ~~/stor/backups/wordpress/$INSTANCE_SHORTNAME/${TIME:?}.website.tar.gz || exit 1;
# prepare manta for the media objects tree
#mmkdir -p ~~/stor/backups/wordpress/$INSTANCE_SHORTNAME/website/
# sync the media objects into manta
#manta-sync /home/node/website/ ~~/stor/backups/wordpress/$INSTANCE_SHORTNAME/website/