mirror of
https://github.com/Sevichecc/pleroma-backup-script.git
synced 2025-04-30 00:39:30 +08:00
Refactor expect script,close #1
This commit is contained in:
parent
8866b65b91
commit
51c4eacbf3
3 changed files with 34 additions and 23 deletions
6
.env
6
.env
|
@ -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
|
||||
|
|
18
backup.sh
18
backup.sh
|
@ -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
33
duplicacy.sh
Normal 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
|
Loading…
Reference in a new issue