Add backup.bash
This commit is contained in:
parent
c999703c1d
commit
daaebe09a9
1 changed files with 17 additions and 0 deletions
17
backup.bash
Normal file
17
backup.bash
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
ARCHIVE="/var/userbak/$(date -I)-bak.tar.gz"
|
||||||
|
tar cfz "${ARCHIVE}" /home
|
||||||
|
echo "Backup stored at ${ARCHIVE}"
|
||||||
|
|
||||||
|
read -r -d $'\0' line < <(find /var/userbak/ -maxdepth 1 -type d -printf '%T@ %p\0' 2>/dev/null | sort -z -n)
|
||||||
|
OLDEST_FILE="${line#* }"
|
||||||
|
|
||||||
|
read -p "Do you want to delete ${OLDEST_FILE}? (y/N)" -n 1 -r
|
||||||
|
echo
|
||||||
|
if [[ $REPLY =~ ^[Yy]$ ]]
|
||||||
|
then
|
||||||
|
rm "${OLDEST_FILE}"
|
||||||
|
echo "Done"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Note: I'm not an expert in Bash, be careful when running this.
|
Loading…
Reference in a new issue