2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-22 21:05:10 +00:00
restic/test/test-key-add-remove.sh

43 lines
976 B
Bash
Raw Normal View History

2014-11-27 23:34:56 +00:00
set -e
dump_repo() {
if [ "$FAILED" == "1" ]; then
2014-12-05 20:45:49 +00:00
tar cvz "$RESTIC_REPOSITORY" | base64 >&2
2014-11-27 23:34:56 +00:00
fi
}
FAILED=1
trap dump_repo 0
prepare
2014-12-05 20:45:49 +00:00
unset RESTIC_PASSWORD
RESTIC_PASSWORD=foo run restic init
RESTIC_PASSWORD=foo run restic key list
2014-11-28 20:59:15 +00:00
2014-12-05 20:45:49 +00:00
RESTIC_PASSWORD=foo RESTIC_NEWPASSWORD=foobar run restic key change
RESTIC_PASSWORD=foobar run restic key list
RESTIC_PASSWORD=foobar RESTIC_NEWPASSWORD=foo run restic key change
2014-11-28 20:59:15 +00:00
2014-11-27 23:34:56 +00:00
OLD_PWD=foo
for i in {1..3}; do
NEW_PWD=bar$i
2014-12-05 20:45:49 +00:00
RESTIC_PASSWORD=$OLD_PWD RESTIC_NEWPASSWORD=$NEW_PWD run restic key add
RESTIC_PASSWORD=$OLD_PWD run restic key list
RESTIC_PASSWORD=$NEW_PWD run restic key list
2014-11-27 23:34:56 +00:00
2014-12-05 20:45:49 +00:00
export RESTIC_PASSWORD=$OLD_PWD
ID=$(restic key list | grep '^\*'|cut -d ' ' -f 1| sed 's/^.//')
unset RESTIC_PASSWORD
RESTIC_PASSWORD=$NEW_PWD run restic key rm $ID
RESTIC_PASSWORD=$NEW_PWD run restic key list
2014-11-27 23:34:56 +00:00
OLD_PWD=bar$i
done
2014-12-05 20:45:49 +00:00
RESTIC_PASSWORD=$OLD_PWD run restic fsck all
2014-11-30 21:43:34 +00:00
2014-11-27 23:34:56 +00:00
cleanup
FAILED=0