Skip to content

Instantly share code, notes, and snippets.

@kapcom01
Created February 21, 2017 15:02
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save kapcom01/ad2c279750830038e8fa3c39ddf2ef5b to your computer and use it in GitHub Desktop.
Save kapcom01/ad2c279750830038e8fa3c39ddf2ef5b to your computer and use it in GitHub Desktop.
#! /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."
@19wolf
Copy link

19wolf commented Jan 22, 2018

Is this for Nextcloud 12 snap?

@Matttthias
Copy link

Matttthias commented Mar 2, 2018

config.php at /snap/nextcloud/current/htdocs/config/config.php does look to be the wrong one ?

The file is at the read only section of the nextcloud snap and can not be restored.

Eventually config.php at /var/snap/nextcloud/current/nextcloud/config/ is the correct one ?

@lmike-mnc
Copy link

also it have to parse config.php for 'datadirectory' =>
for me - there is mounted resource from external (for snap) directory

@Refhi
Copy link

Refhi commented Aug 29, 2018

config.php at /snap/nextcloud/current/htdocs/config/config.php does look to be the wrong one ?

The file is at the read only section of the nextcloud snap and can not be restored.

Eventually config.php at /var/snap/nextcloud/current/nextcloud/config/ is the correct one ?

I concur.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment