mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-04-28 11:50:06 +00:00
refactor(bytestash): auto backup/restore data on update (#13707)
Remove manual backup prompt. Automatically back up and restore the data directory (/opt/bytestash/data or legacy /opt/data) during clean installs to prevent data loss.
This commit is contained in:
parent
0baafa3993
commit
83ef4a5857
1 changed files with 33 additions and 20 deletions
|
|
@ -29,28 +29,41 @@ function update_script() {
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
if check_for_gh_release "bytestash" "jordan-dalby/ByteStash"; then
|
if check_for_gh_release "bytestash" "jordan-dalby/ByteStash"; then
|
||||||
read -rp "${TAB3}Did you make a backup via application WebUI? (y/n): " backuped
|
msg_info "Stopping Services"
|
||||||
if [[ "$backuped" =~ ^[Yy]$ ]]; then
|
systemctl stop bytestash-backend bytestash-frontend
|
||||||
msg_info "Stopping Services"
|
msg_ok "Services Stopped"
|
||||||
systemctl stop bytestash-backend bytestash-frontend
|
|
||||||
msg_ok "Services Stopped"
|
|
||||||
|
|
||||||
CLEAN_INSTALL=1 fetch_and_deploy_gh_release "bytestash" "jordan-dalby/ByteStash" "tarball"
|
msg_info "Backing up data"
|
||||||
|
tmp_dir="/opt/bytestash-data-backup"
|
||||||
msg_info "Configuring ByteStash"
|
mkdir -p "$tmp_dir"
|
||||||
cd /opt/bytestash/server
|
if [[ -d /opt/bytestash/data ]]; then
|
||||||
$STD npm install
|
cp -r /opt/bytestash/data "$tmp_dir"/data
|
||||||
cd /opt/bytestash/client
|
elif [[ -d /opt/data ]]; then
|
||||||
$STD npm install
|
cp -r /opt/data "$tmp_dir"/data
|
||||||
msg_ok "Updated ByteStash"
|
|
||||||
|
|
||||||
msg_info "Starting Services"
|
|
||||||
systemctl start bytestash-backend bytestash-frontend
|
|
||||||
msg_ok "Started Services"
|
|
||||||
else
|
|
||||||
msg_error "PLEASE MAKE A BACKUP FIRST!"
|
|
||||||
exit
|
|
||||||
fi
|
fi
|
||||||
|
msg_ok "Data backed up"
|
||||||
|
|
||||||
|
CLEAN_INSTALL=1 fetch_and_deploy_gh_release "bytestash" "jordan-dalby/ByteStash" "tarball"
|
||||||
|
|
||||||
|
msg_info "Restoring data"
|
||||||
|
if [[ -d "$tmp_dir"/data ]]; then
|
||||||
|
mkdir -p /opt/bytestash/data
|
||||||
|
cp -r "$tmp_dir"/data/* /opt/bytestash/data/
|
||||||
|
rm -rf "$tmp_dir"
|
||||||
|
fi
|
||||||
|
msg_ok "Data restored"
|
||||||
|
|
||||||
|
msg_info "Configuring ByteStash"
|
||||||
|
cd /opt/bytestash/server
|
||||||
|
$STD npm install
|
||||||
|
cd /opt/bytestash/client
|
||||||
|
$STD npm install
|
||||||
|
msg_ok "Updated ByteStash"
|
||||||
|
|
||||||
|
msg_info "Starting Services"
|
||||||
|
systemctl start bytestash-backend bytestash-frontend
|
||||||
|
msg_ok "Started Services"
|
||||||
|
|
||||||
msg_ok "Updated successfully!"
|
msg_ok "Updated successfully!"
|
||||||
fi
|
fi
|
||||||
exit
|
exit
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue