2016-10-18 10:04:13 +00:00
|
|
|
#!/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
|
2023-12-21 14:58:34 +00:00
|
|
|
find "$STORAGE_ROOT/owncloud-backup/"* -maxdepth 0 -type d
|
2016-10-18 10:04:13 +00:00
|
|
|
echo
|
|
|
|
echo "Supply the directory that was created during the last installation as the only commandline argument"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2023-12-21 14:58:34 +00:00
|
|
|
if [ ! -f "$1/config.php" ]; then
|
2016-10-18 10:04:13 +00:00
|
|
|
echo "This isn't a valid backup location"
|
2020-04-11 18:18:44 +00:00
|
|
|
exit 1
|
2016-10-18 10:04:13 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Restoring backup from $1"
|
2023-09-29 12:50:02 +00:00
|
|
|
|
|
|
|
PHP_VER=$(php_version)
|
|
|
|
|
|
|
|
service php$PHP_VER-fpm stop
|
2016-10-18 10:04:13 +00:00
|
|
|
|
2017-04-02 09:19:21 +00:00
|
|
|
# remove the current ownCloud/Nextcloud installation
|
2016-10-18 10:04:13 +00:00
|
|
|
rm -rf /usr/local/lib/owncloud/
|
2017-04-02 09:19:21 +00:00
|
|
|
# restore the current ownCloud/Nextcloud application
|
2016-10-18 10:04:13 +00:00
|
|
|
cp -r "$1/owncloud-install" /usr/local/lib/owncloud
|
|
|
|
|
|
|
|
# restore access rights
|
|
|
|
chmod 750 /usr/local/lib/owncloud/{apps,config}
|
|
|
|
|
2023-12-21 14:58:34 +00:00
|
|
|
cp "$1/owncloud.db" "$STORAGE_ROOT/owncloud/"
|
|
|
|
cp "$1/config.php" "$STORAGE_ROOT/owncloud/"
|
2016-10-18 10:04:13 +00:00
|
|
|
|
2023-12-21 14:58:34 +00:00
|
|
|
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"
|
2016-10-18 10:04:13 +00:00
|
|
|
|
2023-12-21 14:58:34 +00:00
|
|
|
sudo -u www-data "php$PHP_VER" /usr/local/lib/owncloud/occ maintenance:mode --off
|
2016-10-18 10:04:13 +00:00
|
|
|
|
2023-09-29 12:50:02 +00:00
|
|
|
service php$PHP_VER-fpm start
|
2016-10-18 10:04:13 +00:00
|
|
|
echo "Done"
|