Refactor code struture

This commit is contained in:
sevichecc 2023-04-18 01:09:37 +08:00
parent f72209fc63
commit 3b1c7a4a8d
Signed by untrusted user who does not match committer: SevicheCC
GPG key ID: C577000000000000

View file

@ -4,7 +4,10 @@ set SECRET_ACCESS_KEY "YOUR_SECRET_ACCESS_KEY"
set PASSWORD "YOUR_PASSWORD"
set timeout -1
spawn duplicacy backup -threads 4
# Function to handle authentication
proc authenticate {} {
global ACCESS_KEY_ID SECRET_ACCESS_KEY PASSWORD
expect "ID"
send "$ACCESS_KEY_ID\r"
@ -14,18 +17,16 @@ send "$SECRET_ACCESS_KEY\r"
expect "password"
send "$PASSWORD\r"
}
##### (optional) Keep a revision every 7 days for revisions older than 30 days
# expect "completed"
# spawn duplicacy prune -keep 7:30
# Run duplicacy backup command
spawn duplicacy backup -threads 4
authenticate
expect "completed"
# expect "ID"
# send "$ACCESS_KEY_ID\r"
# Run duplicacy prune command (optional)
spawn duplicacy prune -keep 7:30
authenticate
# expect "Secret"
# send "$SECRET_ACCESS_KEY\r"
# expect "password"
# send "$PASSWORD\r"
expect eof
# Allow user interaction after script completion
interact