I'm trying to use an expect script to send borg backups to a remote server and prune old ones. The script to send the backups works just fine. However the script to prune the archive times out before any of the backups are pruned. I have confirmed manually running the command does work. Any thoughts as to why it is timing out?
#!/usr/bin/expect
set folder [exec bash -c "ls -td /home/.snapshots/* | head -n 1"];
set otp [exec oathtool --totp -b KEY];
spawn borg prune --keep-hourly 5 --keep-daily 7 --keep-weekly 4 --keep-monthly 3 --keep-yearly 1 --prefix='home' ssh://user@host:PORT/ARCHIVE
expect "Enter passphrase for key '/root/.ssh/id_ed25519': "
send -- "PASSWORD\r"
expect "Verification code: "
send -- "$otp\r"
expect "Enter passphrase for key ssh://user@host:PORT/ARCHIVE: "
send -- "PASSWORD\r"
expect eof
wait