1
0
Fork 0
mirror of https://github.com/restic/restic.git synced 2024-12-23 08:16:36 +00:00
restic/test/test-key-add-remove.sh
2014-12-05 21:45:49 +01:00

42 lines
976 B
Bash
Executable file

set -e
dump_repo() {
if [ "$FAILED" == "1" ]; then
tar cvz "$RESTIC_REPOSITORY" | base64 >&2
fi
}
FAILED=1
trap dump_repo 0
prepare
unset RESTIC_PASSWORD
RESTIC_PASSWORD=foo run restic init
RESTIC_PASSWORD=foo run restic key list
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
OLD_PWD=foo
for i in {1..3}; do
NEW_PWD=bar$i
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
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
OLD_PWD=bar$i
done
RESTIC_PASSWORD=$OLD_PWD run restic fsck all
cleanup
FAILED=0