From 5c961dc755954d1a2f90248c81aff725cf38466c Mon Sep 17 00:00:00 2001 From: Kyle K Date: Sat, 26 May 2012 00:22:05 -0500 Subject: initial commit --- backup.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 backup.sh (limited to 'backup.sh') diff --git a/backup.sh b/backup.sh new file mode 100755 index 0000000..24009d9 --- /dev/null +++ b/backup.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# notes +# $0 is visible globally, in functions too + +# apparently su -c accepts a command and 1 argument +CMDL_ARGS=$@ +export CMDL_ARGS + +chk_root() +{ + if [[ ! $(id -u) -eq 0 ]]; then + echo "root user required"; + # exec works similar to fork() + exec su -c "\"$0\" $CMDL_ARGS" + exit $? + fi +} + +chk_root $@ +date=$(date +%m.%d.%y) + +echo "backing up mysql" +#mysqldump -u root -p drupal > db-drupal-${date}.sql + +echo "backing up /srv" +tar -cvjf http-${date}.tar.bz2 /srv/http +tar -cvjf git-${date}.tar.bz2 /srv/git + -- cgit v1.2.3