-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add backup script; move all scripts into their own subdir
- Loading branch information
Showing
4 changed files
with
72 additions
and
38 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/sh | ||
|
||
INSTANCE="$1" | ||
|
||
BACKUPDIR=/home/cupapp/Dropbox/backup/$INSTANCE | ||
|
||
if [ "x$INSTANCE" = "x" ]; then | ||
echo "Specify instance" | ||
exit 1 | ||
fi | ||
|
||
FILENAME=$(date +%Y-%m-%d) | ||
if [ -e $BACKUPDIR/$FILENAME ]; then | ||
echo $BACKUPDIR/$FILENAME exists | ||
exit 2 | ||
fi | ||
|
||
USER=$(grep username: $HOME/$INSTANCE/config/databases.yml | sed 's/^.*:\s*\(\S\+\)/\1/') | ||
PASSWORD=$(grep password: $HOME/$INSTANCE/config/databases.yml | sed 's/^.*:\s*\(\S\+\)/\1/') | ||
|
||
BACKUP=$(mktemp -d) | ||
|
||
mkdir ${BACKUP}/$FILENAME | ||
cd $BACKUP | ||
|
||
mysqldump -u $USER --password=$PASSWORD --dump-date $INSTANCE > $FILENAME/sql | ||
cp -a $HOME/$INSTANCE/web/uploads $FILENAME/ | ||
|
||
tar cjf $BACKUPDIR/$FILENAME.tar.bz2 --preserve-permissions --preserve-order $FILENAME/ 2> /dev/null || echo "ERROR DURING TAR" | ||
|
||
cd - > /dev/null | ||
|
||
rm -rf $BACKUP |
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/bin/bash | ||
|
||
BASEDIR=${BASEDIR:-$(dirname $(readlink -f $0))} | ||
BRANCH=${BRANCH:-"master"} | ||
pushd "$BASEDIR" > /dev/null | ||
|
||
function needs_sync_with() | ||
{ | ||
if [ "$(git ls-remote --heads $1 $BRANCH)" == "$(git ls-remote --heads ./. $BRANCH)" ]; then | ||
return 1 | ||
fi | ||
return 0 | ||
} | ||
|
||
function run_cmd() | ||
{ | ||
echo Running: \"$@\" ... | ||
if eval "$@"; then | ||
echo OK | ||
else | ||
echo "Failed..." | ||
exit 1 | ||
fi | ||
} | ||
|
||
if needs_sync_with "origin" ; then | ||
run_cmd git pull --ff-only -- origin $BRANCH | ||
run_cmd git submodule update --init | ||
run_cmd ./symfony propel:migrate | ||
run_cmd ./symfony propel:build-model | ||
run_cmd ./symfony propel:build-forms | ||
run_cmd ./symfony propel:build-filters | ||
run_cmd ./symfony propel:build-sql | ||
run_cmd ./symfony cc | ||
fi | ||
|
||
popd > /dev/null | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
scripts/sync.sh |