1 | #!/bin/bash |
---|
2 | |
---|
3 | # Make sure only root can run our script |
---|
4 | if [ "$(id -u)" != "0" ]; then |
---|
5 | echo "This script must be run as root" 1>&2 |
---|
6 | exit 1 |
---|
7 | fi |
---|
8 | if [[ $HOME != "/root" ]]; then |
---|
9 | echo "This script must be run as root user not via sudo" 1>&2 |
---|
10 | exit 1 |
---|
11 | fi |
---|
12 | |
---|
13 | printf "Have you run /usr/local/bin/backup2kiwi on quince.webarch.net? (y): " |
---|
14 | read REMOTE_SCRIPT_RUN |
---|
15 | if [[ "$REMOTE_SCRIPT_RUN" = "y" ]]; then |
---|
16 | |
---|
17 | # copy files across |
---|
18 | rsync -av /home/live/quince/web/wiki.transitionnetwork.org/www/images/ /web/wiki.dev.transitionnetwork.org/www/images/ |
---|
19 | |
---|
20 | # update database |
---|
21 | cd /home/live/quince/var/backups/mysql/ |
---|
22 | LATEST_MYSQL_DUMP=`ls -t1 *.gz | head -n1` |
---|
23 | tar -zxvf $LATEST_MYSQL_DUMP |
---|
24 | LATEST_MYSQL_DUMP_DIR=`echo $LATEST_MYSQL_DUMP | sed -e s/_.tar.gz//` |
---|
25 | cd $LATEST_MYSQL_DUMP_DIR |
---|
26 | cat *transwiki* | mysql transwiki |
---|
27 | |
---|
28 | else |
---|
29 | exit 1 |
---|
30 | fi |
---|
31 | |
---|
32 | |
---|
33 | |
---|