Skip to content

Commit

Permalink
nc-datadir: make backup if non empty
Browse files Browse the repository at this point in the history
  • Loading branch information
nachoparker committed Nov 18, 2017
1 parent 75fe8d4 commit bccbb5b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 3 additions & 1 deletion changelog.md
@@ -1,5 +1,7 @@

[v0.35.0](https://github.com/nextcloud/nextcloudpi/commit/bd698e5) (2017-11-17) added nc-passwd
[v0.35.1](https://github.com/nextcloud/nextcloudpi/commit/c3195c6) (2017-11-17) nc-datadir: make backup if non empty

[v0.35.0 ](https://github.com/nextcloud/nextcloudpi/commit/05dd8e3) (2017-11-17) added nc-passwd

[v0.34.16](https://github.com/nextcloud/nextcloudpi/commit/d3bade5) (2017-11-17) nc-datadir: refuse to move to SD card

Expand Down
10 changes: 7 additions & 3 deletions etc/nextcloudpi-config.d/nc-datadir.sh
Expand Up @@ -37,12 +37,16 @@ configure()
}
[ -d "$SRCDIR" ] || { echo -e "data directory $SRCDIR not found"; return 1; }

[[ "$SRCDIR" == "$DATADIR_" ]] && { echo -e "INFO: data already there"; return 0; }

# check datadir empty
[ -d $DATADIR_ ] && {
[[ $( find "$DATADIR_" -maxdepth 0 -empty | wc -l ) == 0 ]] && {
echo "$DATADIR_ is not empty"
return 1
local BKP="${DATADIR_}-$( date "+%m-%d-%y" )"
echo "INFO: $DATADIR_ is not empty. Creating backup $BKP"
mv "$DATADIR_" "$BKP"
}
rmdir "$DATADIR_"
rm -rf "$DATADIR_"
}

local BASEDIR=$( dirname "$DATADIR_" )
Expand Down

0 comments on commit bccbb5b

Please sign in to comment.