mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-05-22 00:24:42 +00:00
snowshare: use mv instead of cp for uploads backup to prevent disk fill (#14558)
* snowshare: use mv instead of cp for uploads backup to prevent disk fill Replaces cp -a with mv when backing up and restoring /opt/snowshare/uploads during updates. cp -a duplicated the entire uploads directory on each update, which could fill the disk on instances with large uploads and left stale backup directories accumulating across failed updates. mv is atomic on the same filesystem and avoids any data duplication. Also clears any leftover backup directory before the move to prevent nesting on interrupted updates. Refs TuroYT/snowshare#258 * snowshare: use UPLOAD_DIR env to persist uploads outside install dir Set UPLOAD_DIR=/opt/snowshare_data in the env file so uploads live outside /opt/snowshare and survive CLEAN_INSTALL updates without any backup/restore step. Existing installations are migrated on first update by moving uploads to the new location and appending UPLOAD_DIR to the env file, making the change non-breaking.
This commit is contained in:
+11
-7
@@ -35,16 +35,20 @@ function update_script() {
|
||||
systemctl stop snowshare
|
||||
msg_ok "Stopped Service"
|
||||
|
||||
msg_info "Backing up uploads"
|
||||
[ -d /opt/snowshare/uploads ] && cp -a /opt/snowshare/uploads /opt/.snowshare_uploads_backup
|
||||
msg_ok "Uploads backed up"
|
||||
if ! grep -q '^UPLOAD_DIR=' /opt/snowshare.env 2>/dev/null; then
|
||||
msg_info "Migrating uploads to persistent directory"
|
||||
mkdir -p /opt/snowshare_data
|
||||
if [ -d /opt/snowshare/uploads ] && [ -z "$(ls -A /opt/snowshare_data 2>/dev/null)" ]; then
|
||||
mv /opt/snowshare/uploads/* /opt/snowshare_data/ 2>/dev/null || true
|
||||
mv /opt/snowshare/uploads/.[!.]* /opt/snowshare_data/ 2>/dev/null || true
|
||||
rmdir /opt/snowshare/uploads 2>/dev/null || true
|
||||
fi
|
||||
echo "UPLOAD_DIR=/opt/snowshare_data" >>/opt/snowshare.env
|
||||
msg_ok "Migrated uploads to /opt/snowshare_data"
|
||||
fi
|
||||
|
||||
CLEAN_INSTALL=1 fetch_and_deploy_gh_release "snowshare" "TuroYT/snowshare" "tarball"
|
||||
|
||||
msg_info "Restoring uploads"
|
||||
[ -d /opt/.snowshare_uploads_backup ] && rm -rf /opt/snowshare/uploads && cp -a /opt/.snowshare_uploads_backup /opt/snowshare/uploads
|
||||
msg_ok "Uploads restored"
|
||||
|
||||
msg_info "Updating Snowshare"
|
||||
cd /opt/snowshare
|
||||
$STD npm ci
|
||||
|
||||
@@ -21,12 +21,14 @@ fetch_and_deploy_gh_release "snowshare" "TuroYT/snowshare" "tarball"
|
||||
msg_info "Installing SnowShare"
|
||||
cd /opt/snowshare
|
||||
$STD npm ci
|
||||
mkdir -p /opt/snowshare_data
|
||||
cat <<EOF >/opt/snowshare.env
|
||||
DATABASE_URL="postgresql://$PG_DB_USER:$PG_DB_PASS@localhost:5432/$PG_DB_NAME"
|
||||
NEXTAUTH_URL="http://localhost:3000"
|
||||
NEXTAUTH_SECRET="$(openssl rand -base64 32)"
|
||||
ALLOW_SIGNUP=true
|
||||
NODE_ENV=production
|
||||
UPLOAD_DIR=/opt/snowshare_data
|
||||
EOF
|
||||
set -a
|
||||
source /opt/snowshare.env
|
||||
|
||||
Reference in New Issue
Block a user