48 lines
1.3 KiB
Bash
Executable File
48 lines
1.3 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -eu
|
|
|
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
. $DIR/../help.sh
|
|
. $DIR/../postgres/run --only-source
|
|
|
|
nextcloud_help() {
|
|
echo "./run backup : Lancement de la sauvegarde de Nextcloud"
|
|
echo "./run restore : Restoration de la sauvegarde de Nextcloud"
|
|
}
|
|
|
|
nextcloud_backup() {
|
|
script_env
|
|
BACKUP_DATE_DEFAULT=`date +%Y%m%d_%H%M%S`
|
|
BACKUP_DATE=${BACKUP_DATE:-$BACKUP_DATE_DEFAULT}
|
|
backup_folder_create
|
|
|
|
POSTGRES_BACKUP_FILE=backups/${BACKUP_DATE}_${NEXTCLOUD_DOMAIN}_postgres.sql
|
|
postgres_backup
|
|
|
|
docker run -it --rm -v $HOME/backups/${NEXTCLOUD_DOMAIN}:/backup --volumes-from nextcloud alpine:3.11.6 ash -c "cd /var/www/html && tar cvf /backup/${BACKUP_DATE}_${NEXTCLOUD_DOMAIN}_files.tar ."
|
|
}
|
|
|
|
nextcloud_restore() {
|
|
script_env
|
|
|
|
#postgres_restore
|
|
docker run -it --rm -v $HOME/backups/${NEXTCLOUD_DOMAIN}:/backup -v nextcloud:/var/www/html alpine:3.11.6 ash -c "cd /var/www/html && tar xvf /backup/${BACKUP_DATE}_${NEXTCLOUD_DOMAIN}_files.tar --strip 1"
|
|
}
|
|
|
|
if [ $# -ge 1 ]; then
|
|
if [ "${1}" == "backup" ]; then
|
|
script_start
|
|
nextcloud_backup
|
|
script_end
|
|
elif [ "${1}" == "restore" ]; then
|
|
script_start
|
|
nextcloud_restore
|
|
script_end
|
|
elif [ "${1}" != "--only-source" ]; then
|
|
nextcloud_help
|
|
fi
|
|
else
|
|
nextcloud_help
|
|
fi
|