Refactor expect script,close #1

This commit is contained in:
sevichecc 2023-02-01 01:48:18 +08:00
parent 8866b65b91
commit 51c4eacbf3
Signed by untrusted user who does not match committer: SevicheCC
GPG key ID: C577000000000000
3 changed files with 34 additions and 23 deletions

6
.env
View file

@ -1,9 +1,3 @@
# duplicacy
#SNAPSHOT_ID=
#ACCESS_KEY_ID=
#SECRET_ACCESS_KEY=
#PASSWORD=
PLEROMA_DB=pleroma
PLEROMA_PATH=/var/lib/pleroma
PLEROMA_CONFIG_PATH=/etc/pleroma/config.exs

View file

@ -19,23 +19,7 @@ cp ${PLEROMA_CONFIG_PATH} ${BACKUP_PATH}
echo "————————————upload to remote——————————"
echo "4.backup to remote"
/usr/bin/expect <<EOF
set time 30
spawn duplicacy backup -threads 4
expect {
"ID" { send "$ACCESS_KEY_ID\n"; exp_continue }
"Secret" { send "$SECRET_ACCESS_KEY\n"; exp_continue }
"password" { send "$PASSWORD\n" }
}
# 5. (optional)Keep a revision every 7 days for revisions older than 30 days
# spawn duplicacy prune -keep 7:30
# expect {
# "ID" { send "$ACCESS_KEY_ID\n"; exp_continue }
# "Secret" { send "$SECRET_ACCESS_KEY\n"; exp_continue }
# "password" { send "$PASSWORD\n" }
# }
expect eof
EOF
./duplicacy.sh
echo "restart pleroma"
sudo systemctl start pleroma

33
duplicacy.sh Normal file
View file

@ -0,0 +1,33 @@
#!/usr/bin/expect
set ACCESS_KEY_ID "YOUR_ACCESS_KEY_ID"
set SECRET_ACCESS_KEY "YOUR_SECRET_ACCESS_KEY"
set PASSWORD "YOUR_PASSWORD"
set timeout -1
spawn duplicacy backup -threads 4
expect "ID"
send "$ACCESS_KEY_ID\r"
expect "Secret"
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
# expect "ID"
# send "$ACCESS_KEY_ID\r"
# expect "Secret"
# send "$SECRET_ACCESS_KEY\r"
# expect "password"
# send "$PASSWORD\r"
expect eof
EOF