Created
February 21, 2017 15:02
-
-
Save kapcom01/ad2c279750830038e8fa3c39ddf2ef5b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
user=manolis | |
backups=/home/manolis/backups | |
if [[ $EUID > 0 ]] | |
then echo "Please run as root" | |
exit | |
fi | |
# maintenance mode on | |
nextcloud.occ maintenance:mode --on | |
# if there is no backups directory then create it | |
if [ ! -d $backups ] | |
then | |
mkdir $backups | |
chown $user:$user $backups | |
fi | |
bakdir=$backups/backup-$(date +%Y%m%d) | |
# config | |
echo "Backing up config file..." | |
rsync -Aax /snap/nextcloud/current/htdocs/config/config.php $bakdir/ | |
# database | |
echo "Backing up database..." | |
nextcloud.mysqldump > $bakdir/sqlbkp.bak | |
# nextcloud-data | |
echo "Backing up data..." | |
rsync -Aax /var/snap/nextcloud/common/nextcloud/data/ $bakdir/nextcloud-data/ | |
# owner manolis:manolis | |
chown -R $user:$user $bakdir | |
# maintenance mode off | |
nextcloud.occ maintenance:mode --off | |
echo "Backup finished." | |
echo "When restoring, don't forget to set the correct permissions." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I concur.