Skip to content

Instantly share code, notes, and snippets.

@ifdattic
Created June 11, 2014 06:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ifdattic/4200774f6c6531d7aefb to your computer and use it in GitHub Desktop.
Save ifdattic/4200774f6c6531d7aefb to your computer and use it in GitHub Desktop.
Initial duplicity automation script using expect (not finished)
set GOOGLE_ACCOUNT "foobar"
set GOOGLE_PASSWORD "foobar"
# # Watch out !!!
# # If you have a '$' in your passphrase, make sure you escape it with '\'
set GNUPG_PASSPHRASE "foobar"
set VERBOSITY_LEVEL 8
set GOOGLE_BACKUP_DIRECTORY "duplicity-backup"
set SOURCE "/Users/foobar/some_dir/"
#!/usr/bin/expect
proc srcfile-safe {filename args} {
global argv
global GOOGLE_ACCOUNT GOOGLE_PASSWORD GNUPG_PASSPHRASE VERBOSITY_LEVEL GOOGLE_BACKUP_DIRECTORY SOURCE
set save $argv
set argv $args
set rc [catch {source $filename} ret]
set argv $save
return -code $rc $ret
}
srcfile-safe config
spawn duplicity -v$VERBOSITY_LEVEL $SOURCE gdocs://$GOOGLE_ACCOUNT/$GOOGLE_BACKUP_DIRECTORY
expect "Password" { send "$GOOGLE_PASSWORD\r" }
expect "GnuPG passphrase:" { send "$GNUPG_PASSPHRASE\r" }
expect "Retype passphrase" { send "$GNUPG_PASSPHRASE\r" }
interact
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment