Update backup-keepassxc-db.sh

This commit is contained in:
Alexander Rosenberg 2023-05-09 01:22:44 -07:00
parent f7535dfe36
commit 89673bbce8
Signed by: Zander671
GPG Key ID: 5FD0394ADBD72730

View File

@ -1,4 +1,18 @@
#!/usr/bin/env zsh #!/usr/bin/env zsh
(( ${#} < 1 )) && { echo 'Device name is required'; exit 1 }
local devdir="${HOME}/nextcloud/KeePassXC/${2}"
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
local datetime="$(date +'d%d-%m-%Y_t%H-%M-%S')" local datetime="$(date +'d%d-%m-%Y_t%H-%M-%S')"
local filename="keepassxc-db-backup-${datetime}.tar.gz" local filename="keepassxc-db-backup-${datetime}.tar.gz"
tar -caf "${HOME}/nextcloud/KeePassXC/${filename}" "${HOME}/.keepassxc" tar -caf \
"${devdir}/${filename}" \
"${HOME}/.keepassxc"