Create incremental backups in a git-annex repository
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test.sh 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/usr/bin/env bash
  2. #
  3. # git-annex-backup - Create incremental backups in a git-annex repository.
  4. # Copyright © 2016 Peter Colberg.
  5. # Distributed under the MIT license. (See accompanying file LICENSE.)
  6. #
  7. export PATH="$PWD:$PATH"
  8. test_date() {
  9. export GIT_ANNEX_BACKUP_DATE=$1
  10. export GIT_AUTHOR_DATE=$1
  11. export GIT_AUTHOR_NAME=root
  12. export GIT_AUTHOR_EMAIL=root@localhost
  13. export GIT_COMMITTER_DATE=$GIT_AUTHOR_DATE
  14. export GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
  15. export GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
  16. }
  17. test_backup() {
  18. local i=1
  19. while [[ "$i" -le "$#" ]]; do
  20. printf '%s' "${!i}" > "test.$1.$i.txt"
  21. i=$(( $i + 1 ))
  22. done
  23. }
  24. export -f test_backup
  25. if [[ -d test ]]; then
  26. chmod -R u+w test
  27. rm -rf test
  28. fi
  29. mkdir test
  30. (cd test && git init -q && echo "* annex.backend=SHA256" > .git/info/attributes && git annex init -q)
  31. for d in {02..31}; do
  32. (cd test && test_date "1970-01-${d}T08:00:00+08:00" && git-annex-backup.sh backup -i 1d -i 1w -i 4w test_backup)
  33. (cd test && test_date "1970-01-${d}T08:00:01+08:00" && git-annex-backup.sh prune --expire=2w)
  34. done
  35. diff "test.log" <(git -C test log --reverse --pretty=fuller --name-status HEAD) || exit 1
  36. chmod -R u+w test
  37. rm -rf test