mirror of
https://github.com/grocy/grocy.git
synced 2026-03-28 07:39:25 +01:00
By making the date in backup filename ISO 8601 compliant (year-month-day) an alphabetical sort of the backups automatically will be a chronological sort of the backups. This is more convenient. As the automatic deletion of backups older than 60 days relies on the modified date of the file (and not the filename), this will continue to work without problems. See also: https://www.xkcd.com/1179/
36 lines
968 B
Bash
Executable File
36 lines
968 B
Bash
Executable File
#!/bin/bash
|
|
|
|
GROCY_RELEASE_URL=https://releases.grocy.info/latest
|
|
|
|
|
|
echo Start updating Grocy
|
|
|
|
set -e
|
|
shopt -s extglob
|
|
pushd `dirname $0` > /dev/null
|
|
|
|
backupBundleFileName="backup_`date +%Y-%m-%d_%H-%M-%S`.tgz"
|
|
echo Making a backup of the current installation in ./data/backups/$backupBundleFileName
|
|
mkdir -p ./data/backups > /dev/null
|
|
touch ./data/backups/$backupBundleFileName
|
|
tar -zcvf ./data/backups/$backupBundleFileName --exclude ./data/backups . > /dev/null
|
|
find ./data/backups/*.tgz -mtime +60 -type f -delete
|
|
|
|
echo Deleting everything except ./data and this script
|
|
rm -rf !(data|update.sh) > /dev/null
|
|
|
|
echo Emptying ./data/viewcache
|
|
rm -rf ./data/viewcache/* > /dev/null
|
|
|
|
echo Downloading latest release
|
|
rm -f ./grocy-latest.zip > /dev/null
|
|
wget $GROCY_RELEASE_URL -q -O ./grocy-latest.zip > /dev/null
|
|
|
|
echo Unzipping latest release
|
|
unzip -o ./grocy-latest.zip > /dev/null
|
|
rm -f ./grocy-latest.zip > /dev/null
|
|
|
|
popd > /dev/null
|
|
|
|
echo Finished updating Grocy
|