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