Skip to content

Commit

Permalink
add backup script; move all scripts into their own subdir
Browse files Browse the repository at this point in the history
  • Loading branch information
zsol committed Mar 28, 2011
1 parent 3889b0a commit 69ddab3
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 38 deletions.
33 changes: 33 additions & 0 deletions scripts/backup.sh
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.
38 changes: 38 additions & 0 deletions scripts/sync.sh
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

38 changes: 0 additions & 38 deletions sync.sh

This file was deleted.

1 change: 1 addition & 0 deletions sync.sh

0 comments on commit 69ddab3

Please sign in to comment.