2015-09-08 06:43:03 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
2016-05-06 03:07:06 +02:00
|
|
|
# DokuWiki backup/restore script
|
2015-09-08 06:43:03 +02:00
|
|
|
#
|
2016-05-06 03:07:06 +02:00
|
|
|
# WARNING: It will mount current directory as a volume.
|
|
|
|
# Related files should be in current directory.
|
|
|
|
#
|
|
|
|
|
|
|
|
cd "$(dirname "${BASH_SOURCE[0]}")"
|
2015-09-08 06:43:03 +02:00
|
|
|
|
2018-07-20 09:20:56 +02:00
|
|
|
mkdir -p backups
|
|
|
|
|
2015-09-08 06:43:03 +02:00
|
|
|
ACTION=${1:?action is required}
|
|
|
|
FILENAME=${2:-dw-backup-$(date +%Y%m%d-%H%M%S).tar.gz}
|
|
|
|
CONTAINER=${3:-dokuwiki_dokuwiki_1}
|
|
|
|
|
|
|
|
do_help() {
|
|
|
|
echo 'USAGE: ./admin.sh ACTION [FILENAME] [CONTAINER]'
|
|
|
|
}
|
|
|
|
|
|
|
|
do_backup() {
|
|
|
|
echo "backup to $FILENAME"
|
2018-07-20 09:20:56 +02:00
|
|
|
docker run --rm --volumes-from $CONTAINER -v `pwd`/backups:/backup alpine \
|
2015-09-08 06:43:03 +02:00
|
|
|
tar czf /backup/$FILENAME /var/www/html
|
|
|
|
}
|
|
|
|
|
|
|
|
do_restore() {
|
|
|
|
echo "restore from $FILENAME"
|
2018-07-20 09:20:56 +02:00
|
|
|
docker run --rm --volumes-from $CONTAINER -v `pwd`/backups:/backup alpine \
|
2015-09-08 06:43:03 +02:00
|
|
|
tar xzf /backup/$FILENAME -C /
|
|
|
|
}
|
|
|
|
|
|
|
|
main() {
|
|
|
|
case "$ACTION" in
|
|
|
|
backup)
|
|
|
|
do_backup
|
|
|
|
;;
|
|
|
|
restore)
|
|
|
|
do_restore
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
do_help
|
|
|
|
exit 1;
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
main
|