mirror of
https://github.com/netinvent/npbackup.git
synced 2025-09-08 05:54:25 +08:00
Add restic source update script
This commit is contained in:
parent
d9b0273e05
commit
163bd608c6
1 changed files with 44 additions and 0 deletions
44
RESTIC_SOURCE_FILES/update_restic.sh
Executable file
44
RESTIC_SOURCE_FILES/update_restic.sh
Executable file
|
@ -0,0 +1,44 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Quick script to update restic binaries
|
||||
|
||||
export ORG=restic
|
||||
export REPO=restic
|
||||
LATEST_VERSION=$(curl -s https://api.github.com/repos/${ORG}/${REPO}/releases/latest | grep "tag_name" | cut -d'"' -f4)
|
||||
echo Latest restic version ${LATEST_VERSION}
|
||||
|
||||
for platform in "windows_386" "windows_amd64" "linux_arm" "linux_arm64" "linux_amd64" "darwin_amd64" "freebsd_amd64"; do
|
||||
restic_filename="restic_${LATEST_VERSION//v}_${platform}"
|
||||
if [ ! -f "${restic_filename}" ]; then
|
||||
echo "Moving earlier version to archive"
|
||||
[ -d ARCHIVES ] || mkdir ARCHIVES
|
||||
mv restic_*_${platform} ARCHIVES/ > /dev/null 2>&1
|
||||
echo "Downloading ${restic_filename}"
|
||||
if [ "${platform:0:7}" == "windows" ]; then
|
||||
ext=zip
|
||||
else
|
||||
ext=bz2
|
||||
fi
|
||||
curl -OL https://github.com/restic/restic/releases/download/${LATEST_VERSION}/restic_${LATEST_VERSION//v}_{$platform}.${ext}
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Failed to download ${restic_filename}"
|
||||
exit 1
|
||||
else
|
||||
if [ -f "${restic_filename}.bz2" ]; then
|
||||
bzip2 -d "${restic_filename}.bz2"
|
||||
elif [ -f "${restic_filename}.zip" ]; then
|
||||
unzip "${restic_filename}.zip"
|
||||
else
|
||||
echo "Archive ${restic_filename} not found"
|
||||
exit 1
|
||||
fi
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Failed to decompress ${restic_filename}.bz2"
|
||||
exit 1
|
||||
fi
|
||||
[ -f "${restic_filename}.zip" ] && rm -f "${restic_filename}.zip"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Finished updating restic binaries"
|
Loading…
Add table
Reference in a new issue