Skip to content

Instantly share code, notes, and snippets.

@sobi3ch
Last active July 28, 2017 06:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sobi3ch/b40659a1c0569a374761 to your computer and use it in GitHub Desktop.
Save sobi3ch/b40659a1c0569a374761 to your computer and use it in GitHub Desktop.
The Father, the Son and the Grandfather: A Basic Backup Strategy
#!/bin/sh
# Created by: Alex Saavedra
# Date created: 2011-05-11
# Last modified: 2010-05-11
# Purpose: ProcessMaker backup.
# Change log:
# Syntax:
# backup.sh <periodicity> <period>
# Parameters:
# <periodicity> = weekly, monthly, yearly
# <period> = specific week day, month or year
# Help
HELP="The backup is invoked as follows:\n"
HELP=$HELP" /root/backup.sh <type> <periodicity>\n"
HELP=$HELP"where:n"
HELP=$HELP" periodicity = weekly, monthly, yearly\n"
HELP=$HELP" period = specific day, month or year\n"
# Destination backup file construct.
DST=/path/to/backups/processmaker_$1_$2.tgz
# Now DST is similar to "/path/to/backups/processmaker_weekly_03.tgz"
# SQL dump file name construct
SQL=/tmp/processmaker_$1_$2.sql
if [ -z "$2" ]
then
# In recent distributions you may not need the -e parameter.
echo -e $HELP
exit 1
fi
# timestamp logging
echo "Starting date and time: $(date)"
# database dump: wf_workflow, rb_workflow and rp_workflow are ProcessMaker databases.
mysqldump --opt --add-drop-table -B -u root -psecret --result-file=$SQL wf_workflow rb_workflow rp_workflow
# use the following line if you prefer a backup of all databases:
#mysqldump --opt --add-drop-table --all-databases -u root -psecret --result-file=$SQL
# Source file construct
SRC=/opt/processmaker/ $SQL
# actual backup
tar -cvzf $DST $SRC > /dev/null
echo "Finished date and time: $(date)"
echo "The backup file $DST was successfully created."
ls -lh $DST
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment