owncloud-restore.sh 1.51 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
#!/bin/bash
#
# This script will restore the backup made during an installation
source /etc/mailinabox.conf # load global vars

if [ -z "$1" ]; then
	echo "Usage: owncloud-restore.sh <backup directory>"
	echo
	echo "WARNING: This will restore the database to the point of the installation!"
	echo "         This means that you will lose all changes made by users after that point"
	echo
	echo
	echo "Backups are stored here: $STORAGE_ROOT/owncloud-backup/"
	echo
	echo "Available backups:"
	echo
	find $STORAGE_ROOT/owncloud-backup/* -maxdepth 0 -type d
	echo
	echo "Supply the directory that was created during the last installation as the only commandline argument"
	exit
fi

if [ ! -f $1/config.php ]; then
	echo "This isn't a valid backup location"
	exit
fi

echo "Restoring backup from $1"
service php5-fpm stop
30
service php7.0-fpm stop
31

32
# remove the current ownCloud/Nextcloud installation
33
rm -rf /usr/local/lib/owncloud/
34
# restore the current ownCloud/Nextcloud application
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
cp -r  "$1/owncloud-install" /usr/local/lib/owncloud

# restore access rights
chmod 750 /usr/local/lib/owncloud/{apps,config}

cp "$1/owncloud.db" $STORAGE_ROOT/owncloud/
cp "$1/config.php" $STORAGE_ROOT/owncloud/

ln -sf $STORAGE_ROOT/owncloud/config.php /usr/local/lib/owncloud/config/config.php
chown -f -R www-data.www-data $STORAGE_ROOT/owncloud /usr/local/lib/owncloud
chown www-data.www-data $STORAGE_ROOT/owncloud/config.php

sudo -u www-data php /usr/local/lib/owncloud/occ maintenance:mode --off

service php5-fpm start
50
service php7.0-fpm start
51
echo "Done"