geosolutions-it/scripts

Backup script move files before destroying them

Closed this issue · 1 comments

I'm looking at the geoserver datadir backup and restore script: https://github.com/geosolutions-it/scripts/blob/master/utils/datadir_backup.sh#L77

When restoring it does:

# move the old directory
mv ${DATA_DIR} ${BACKUPDIR}moved
#remove the old data dir
rm -Rf ${BACKUPDIR}moved
mkdir ${DATA_DIR}

Shouldn't "rm" be before "mv", so the old moved dir is deleted before moving the current data dir?
This way, if the restore fails, the current datadir is preserved.

Yes a remove before should allow to avoid errors if the directory already exists. It also allows to keep the old datadir if the restore operation fails. You can open a new issue or use a enhancement label.