mirror of
https://github.com/nextcloud/nextcloudpi.git
synced 2026-01-10 15:12:01 -03:30
nc-restore: Fix potential dataloss when restoring backup (fixes #1417)
- nc-restore: Keep old data directory if present - nc-restore: Temporarily move and restore user files during nc-restore Signed-off-by: Tobias K <6317548+theCalcaholic@users.noreply.github.com> Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com>
This commit is contained in:
parent
5178e5553f
commit
97085dbc3f
@ -114,6 +114,7 @@ tar $compress_arg -cf "$destfile" \
|
||||
--exclude "nextcloud/data/*/files_versions/*" \
|
||||
--exclude "nextcloud/data/ncp-update-backups" \
|
||||
--exclude "nextcloud/data/__groupfolders" \
|
||||
--exclude "nextcloud/.data_*" \
|
||||
-C $basedir nextcloud/ \
|
||||
|| {
|
||||
echo "error generating backup"
|
||||
|
||||
@ -63,9 +63,31 @@ tar $compress_arg -xf "$BACKUPFILE" -C "$TMPDIR" || exit 1
|
||||
## RESTORE FILES
|
||||
|
||||
echo "restore files..."
|
||||
[[ -d "$NCDIR/data" ]] && {
|
||||
DATA_BKP_DIR="$(mktemp -d -p "$NCDIR/.." nc-data-XXXXXX)"
|
||||
mv -T "$NCDIR/data" "$DATA_BKP_DIR/"
|
||||
}
|
||||
rm -rf "$NCDIR"
|
||||
mv -T "$TMPDIR"/nextcloud "$NCDIR" || { echo "Error restoring base files"; exit 1; }
|
||||
|
||||
if [[ -n "$DATA_BKP_DIR" ]]
|
||||
then
|
||||
echo "Restoring $NCDIR/data..."
|
||||
target="$NCDIR/data"
|
||||
[[ -d "$target" ]] && target="$NCDIR/.data_$(date)"
|
||||
mv -T "$DATA_BKP_DIR" "$target"
|
||||
else
|
||||
fi
|
||||
|
||||
if [[ -n "$DATA_BKP_DIR" ]]
|
||||
then
|
||||
echo "Restoring $NCDIR/data..."
|
||||
target="$NCDIR/data"
|
||||
[[ -d "$target" ]] && target="$NCDIR/.data_$(date)"
|
||||
mv -T "$DATA_BKP_DIR" "$target"
|
||||
else
|
||||
fi
|
||||
|
||||
# update NC database password to this instance
|
||||
sed -i "s|'dbpassword' =>.*|'dbpassword' => '$DBPASSWD',|" /var/www/nextcloud/config/config.php
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user