41 lines
646 B
Bash
41 lines
646 B
Bash
#!/bin/bash
|
|
|
|
# Overwrite the previous backup with the current version
|
|
|
|
./qfixdpl -v > info
|
|
|
|
gzip -k qfixdpl
|
|
|
|
cp qfixdpl.gz "backups"
|
|
cp conf.toml "backups"
|
|
cp info "backups"
|
|
|
|
# Keep a copy with version info
|
|
|
|
ver_all=$(./qfixdpl -v | grep Build)
|
|
arr=("$ver_all")
|
|
ver_aux=${arr[1]}
|
|
ver=${ver_aux::-1}
|
|
echo "$ver"
|
|
|
|
mkdir -p "backups/$ver"
|
|
|
|
mv qfixdpl.gz "backups/$ver"
|
|
mv info "backups/$ver"
|
|
cp conf.toml "backups/$ver"
|
|
|
|
# Only keep the indicated number of backups. Delete the oldests ones.
|
|
|
|
i=0
|
|
keep=10
|
|
|
|
for d in $(ls -dt backups/*/); do
|
|
if [[ "$i" -gt "$keep" ]]; then
|
|
echo "Deleting: ${d}"
|
|
else
|
|
echo "Keep: ${d}"
|
|
fi
|
|
((i++))
|
|
done
|
|
|