backup-keepassxc-db.sh 484 B

12345678910111213141516171819
  1. #!/usr/bin/env zsh
  2. (( ${#} < 1 )) && { echo 'Device name is required'; exit 1 }
  3. local devdir="${HOME}/nextcloud/KeePassXC/${1}"
  4. if ! [ -d "${devdir}" ]; then
  5. mkdir "${devdir}" || exit 1
  6. fi
  7. # Remove files older than 30 days (files modified more than 30 days ago)
  8. find "${devdir}" -depth -mtime +30 -delete
  9. local datetime="$(date +'d%d-%m-%Y_t%H-%M-%S')"
  10. local filename="keepassxc-db-backup-${datetime}.tar.gz"
  11. tar -caf \
  12. "${devdir}/${filename}" \
  13. "${HOME}/.keepassxc"