Created
March 17, 2016 18:08
-
-
Save matheuss/bad65549b2142a5bed74 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# APP_DIR="./test" | |
APP_DIR="/srv/production/tomcat/webapps/ROOT" | |
function dir_not_supplied { | |
echo "Directory not supplied: assuming '.'" | |
BACKUP_DIR="./backup-folders" | |
} | |
function backup { | |
rm -rf $BACKUP_DIR | |
mkdir $BACKUP_DIR | |
mkdir $BACKUP_DIR/images | |
cp -r $APP_DIR/data $BACKUP_DIR | |
echo '/data backuped' | |
cp $APP_DIR/images/*-banner.png $BACKUP_DIR/images | |
echo '/images/*-banner.png backuped' | |
cp -r $APP_DIR/propeller $BACKUP_DIR | |
echo '/propeller backuped' | |
cp -r $APP_DIR/published $BACKUP_DIR | |
echo '/published backuped' | |
echo 'DONE' | |
} | |
function restore { | |
echo "Are you sure that you want to restore '$BACKUP_DIR' contents? (y/n)" | |
read yn | |
if [ $yn != "y" ]; then | |
echo "Aborting" | |
exit | |
fi | |
cp -r $BACKUP_DIR/data $APP_DIR | |
echo '/data restored' | |
cp $BACKUP_DIR/images/*-banner.png $APP_DIR/images | |
echo '/images/*-banner.png restored' | |
cp -r $BACKUP_DIR/propeller $APP_DIR | |
echo '/propeller restored' | |
cp -r $BACKUP_DIR/published $APP_DIR | |
echo '/published restored' | |
echo 'DONE' | |
} | |
if [ -n "$1" ]; then | |
if [ $1 = "-r" ] || [ $1 = "--restore" ]; then | |
if [ -z "$2" ]; then | |
dir_not_supplied | |
else | |
BACKUP_DIR="$2" | |
fi | |
restore | |
else | |
BACKUP_DIR="$1" | |
backup | |
fi | |
else | |
dir_not_supplied | |
backup | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment