45 lines
1.7 KiB
Bash
Executable File
45 lines
1.7 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
# this one makes a copy of the whole /var/www/html from sbz
|
|
#
|
|
# to recover nextcloud data see: https://docs.nextcloud.com/server/13/admin_manual/maintenance/restore.html
|
|
#
|
|
# rsync args:
|
|
# -a, --archive archive mode; equals -rlptgoD (no -H,-A,-X)
|
|
# -r, --recursive recurse into directories
|
|
# -l, --links When symlinks are encountered, recreate the symlink on the destination.
|
|
# -h, --human-readable Output numbers in a more human-readable format.
|
|
|
|
PORT="42523"
|
|
KEY="./sbz_keyless"
|
|
USER_AT_HOST="rob@spaceboyz.net"
|
|
|
|
SBZ_MOUNT_PATH=/home/rob/tmp_mnt
|
|
SOURCE_PATH=/var/www/html/marker
|
|
DEST_PATH_FILES=/tmp/nextcloud-rsync/
|
|
DEST_PATH_DB=/tmp/nextcloud-rsync-db/
|
|
NEXTCLOUD_PATH=/var/www/html/nextcloud
|
|
|
|
|
|
# mount my lxc container into my home on sbz
|
|
ssh -p $PORT -i $KEY $USER_AT_HOST "sudo mount /dev/mapper/vms-home--rob $SBZ_MOUNT_PATH"
|
|
|
|
# put nextcloud into maintenance, outside the home-rob container
|
|
ssh -p $PORT -i $KEY $USER_AT_HOST "sudo sed -i \"s|'maintenance' => false|'maintenance' => true|g\" $SBZ_MOUNT_PATH$NEXTCLOUD_PATH/config/config.php"
|
|
|
|
# rsync download from sbz
|
|
rsync -arlh -e "ssh -p $PORT -i $KEY" $USER_AT_HOST:${SBZ_MOUNT_PATH}${SOURCE_PATH} ${DEST_PATH_FILES}
|
|
|
|
# turn off nextcloud maintenance, outside the home-rob container
|
|
ssh -p $PORT -i $KEY $USER_AT_HOST "sudo sed -i \"s|'maintenance' => true|'maintenance' => false|g\" $SBZ_MOUNT_PATH$NEXTCLOUD_PATH/config/config.php"
|
|
|
|
# umount my container
|
|
ssh -p $PORT -i $KEY $USER_AT_HOST "sudo umount $SBZ_MOUNT_PATH"
|
|
|
|
|
|
### Get all databases
|
|
|
|
cd $DEST_PATH_DB
|
|
curl https://rob.spaceboyz.net/backup_all_databases_cMxNrCTVLBPrNo6qaonojeejCvCepekwssh/dump_all_databases.php
|
|
wget https://rob.spaceboyz.net/backup_all_databases_cMxNrCTVLBPrNo6qaonojeejCvCepekwssh/dumps.zip
|