This script currently assumes that 'cmscli' is in the CMSMS root directory (but that's easily changed). It clears the cache, does the db-dump and generates a .tar.gz file.
It demonstrates the usefulness of cmscli as it does not require looking at or remembering the cmsms database credentials.
Your mileage may vary... but you can use this to create your own simple snapshot script.
Code: Select all
#!/bin/bash
_outfile='cmsms_backup.tar.gz'
if [ ! -d tmp -o ! -f lib/version.php ]; then
echo "This is not a CMSMS root directory"
exit 1
fi
if [ ! -w . ]; then
echo "No write permission to "`pwd`
exit 1
fi
if [ -f $_outfile -a ! -w $_outfile ]; then
echo "$_outfile exists but is not writable"
exit 1
fi
./cmscli db-dump -F tmp/dump.sql && ./cmscli cache-clear && tar zcf $_outfile . && echo "Done. Backup is in $_outfile"
- taking the site down, and backup before and after doing the backup
- relying on cmscli being in the current path.
- configuring an output file via an option (getopt).