Skip to content

Commit

Permalink
Adds a usage section to the backup script
Browse files Browse the repository at this point in the history
Closes #18

Signed-off-by: Justin Yost <[email protected]>
  • Loading branch information
justinyost committed Apr 17, 2015
1 parent 084fc2a commit 119e45c
Showing 1 changed file with 65 additions and 1 deletion.
66 changes: 65 additions & 1 deletion backup.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,69 @@
#!/usr/bin/env bash

#---------------------------------------------------------------------
usage () {
cat <<EOT
${0##*/}
Backup a directory, MySQL, PostgreSQL, MongoDB and SQLite databases
using a rotating scheme of daily, weekly and monthly backups.
To use, move the config.sh.default included in the repo to config.sh
and edit the various settings as need.
When it runs for each feature turned on:
* Creates the backup
* Moves to the BACKUP_LOCAL_PATH folder
* Names the backup as daily_db_backup_${TOOL_BEING_BACKED_UP}....
* If it is 1st day of the week, copys it to
weekly_${TOOL_BEING_BACKED_UP}....
* If it is 1st day of the month, copys it to
monthly_${TOOL_BEING_BACKED_UP}.....
* Daily backups that are older than a week are deleted
* Weekly backups that are older than a 28 days (4 weeks) are deleted
* Monthly backups that are older than a 365 days (1 year) are deleted
* If the AMAZON_S3_UPLOAD_ACTIVE is set to true, the BACKUP_LOCAL_PATH
folder is synched with a S3 Bucket
Requires:
S3 Command Line Tools installed: http://s3tools.org/s3cmd
Usage:
${0##*/}
Bash Variables Set From "config.sh":
# MySQL Settings
MYSQL_DB_USERNAME=ThisIsYourMySQLUsername
MYSQL_DB_PASSWORD=ThisIsYourMySQLRootPassword
# PostgreSQL Settings
POSTGRES_DB_USERNAME=ThisIsYourPostgresUsername
# MongoDB Settings
MONGO_DB_USERNAME=ThisIsYourMongoDBUsername
MONGO_DB_PASSWORD=ThisIsYourMongoDBPassword
# SQLite Settings
SQLITE_PATH=/Users/jtyost2/Sites/jtyost2/S3_Backup/testing
# Webroot Backup Settings
WEBROOT_LOCAL_PATH=/Users/jtyost2/Desktop
BACKUP_LOCAL_PATH=/Users/jtyost2/Sites/jtyost2/testing_dump/
AMAZON_S3_PATH=s3://BucketName/folder_in_bucket/
# Turn on or off features
MYSQL_DUMP_ACTIVE=false
POSTGRESQL_DUMP_ACTIVE=false
MONGODB_DUMP_ACTIVE=false
SQLITE_DUMP_ACTIVE=true
AMAZON_S3_UPLOAD_ACTIVE=false
EOT

exit ${1:-0} # Exit with code 0 unless an arg is passed to the method.
}
if [ "$1" = '-h' ]; then
usage
fi

#Import settings from ./config.sh
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source ${DIR}/config.sh
Expand Down Expand Up @@ -101,4 +165,4 @@ then
s3cmd sync --delete-removed ${BACKUP_LOCAL_PATH} ${AMAZON_S3_PATH}
fi

echo "S3Backup Completed For: ${THEDATE}" >&2
echo "S3Backup Completed For: ${THEDATE}" >&2

0 comments on commit 119e45c

Please sign in to comment.