Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/nextcloudpi.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthecalcaholic <6317548+theCalcaholic@users.noreply.github.com>2022-09-28 15:20:14 +0300
committerthecalcaholic <6317548+theCalcaholic@users.noreply.github.com>2022-09-28 17:14:00 +0300
commit412efad20f27c7af17473615d60deefad3bbcdfa (patch)
tree6a0a0b102af2f3e5c4089d645db5dd57d595dbbd
parent1a80ecbfc900ee1e241e9332aa0cbab749c3b5ec (diff)
run-parts.sh: Backup docker instance when starting container
Signed-off-by: thecalcaholic <6317548+theCalcaholic@users.noreply.github.com>
-rwxr-xr-xbuild/docker/debian-ncp/run-parts.sh26
1 files changed, 25 insertions, 1 deletions
diff --git a/build/docker/debian-ncp/run-parts.sh b/build/docker/debian-ncp/run-parts.sh
index 0099a5a1..abcde008 100755
--- a/build/docker/debian-ncp/run-parts.sh
+++ b/build/docker/debian-ncp/run-parts.sh
@@ -13,7 +13,31 @@ sed -i 's|/data-ro|/data|' "/etc/mysql/mariadb.conf.d/90-ncp.cnf" || true
trap cleanup SIGTERM
# if an empty volume is mounted to /data, pre-populate it
-[[ $( ls -1A /data | wc -l ) -eq 0 ]] && { echo "Initializing empty volume.."; cp -raT /data-ro /data; }
+if [[ $( ls -1A /data | wc -l ) -eq 0 ]]
+then
+ echo "Initializing empty volume.."
+ cp -raT /data-ro /data
+else
+ echo "Cleanup old startup backups..."
+ BKPS="$(ls -1t "$BKPDIR"/nextcloud-bkp_*.tar.gz 2>/dev/null)"
+ while read -r bkp
+ do
+ rm -f "$BKPDIR/$bkp"
+ done <"$(echo "$BKPS" | tail -n + 5)"
+ BKPDIR=/data/ncp-startup-backups/
+ WITH_DATA=no
+ COMPRESSED=yes
+ LIMIT=0
+ mkdir -p "$BKPDIR"
+ echo "Back up current instance..."
+ set +eE
+ if ncp-backup "$BKPDIR" "$WITH_DATA" "$COMPRESSED" "$LIMIT"
+ then
+ echo "Backup stored at '$BKPDIR/$(ls -1t "$BKPDIR"/nextcloud-bkp_*.tar.gz 2>/dev/null | head -n1)'"
+ else
+ echo 'WARN: Backup creation failed'
+ fi
+fi
# wrapper to simulate update-rc.d
cat > /usr/local/sbin/update-rc.d <<'EOF'