random-scripts/backup-keepassxc-db.sh

19 lines
484 B
Bash
Raw Permalink Normal View History

2023-05-09 00:56:37 -07:00
#!/usr/bin/env zsh
2023-05-09 01:22:44 -07:00
(( ${#} < 1 )) && { echo 'Device name is required'; exit 1 }
2023-05-09 01:35:38 -07:00
local devdir="${HOME}/nextcloud/KeePassXC/${1}"
2023-05-09 01:22:44 -07:00
if ! [ -d "${devdir}" ]; then
mkdir "${devdir}" || exit 1
fi
# Remove files older than 30 days (files modified more than 30 days ago)
find "${devdir}" -depth -mtime +30 -delete
2023-05-09 00:56:37 -07:00
local datetime="$(date +'d%d-%m-%Y_t%H-%M-%S')"
local filename="keepassxc-db-backup-${datetime}.tar.gz"
2023-05-09 01:22:44 -07:00
tar -caf \
"${devdir}/${filename}" \
"${HOME}/.keepassxc"