Created
March 19, 2012 00:43
-
-
Save niallo/2087754 to your computer and use it in GitHub Desktop.
Automated, encrypted backups via Puppet, Duplicity and GnuPG
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class s3-backups { | |
package { "duplicity": | |
ensure => "installed" | |
} | |
package { "python-boto": | |
ensure => "installed" | |
} | |
package { "gnupg": | |
ensure => "installed" | |
} | |
exec { "import-keys" : | |
command => "/usr/bin/gpg --import /root/s3-backup-privkey.key /root/s3-backup-pubkey.key", | |
require => [ | |
Package["gnupg"], | |
File["/root/s3-backup-privkey.key"], | |
File["/root/s3-backup-pubkey.key"], | |
], | |
unless => "/usr/bin/gpg --list-keys | grep 6418B748" | |
} | |
exec { "import-trust" : | |
command => "/usr/bin/gpg --import-ownertrust < /root/s3-backup-key-ownertrust", | |
require => [ | |
Exec["import-keys"], | |
File["/root/s3-backup-key-ownertrust"] | |
], | |
unless => "/usr/bin/test $(/usr/bin/gpg --export-ownertrust | /usr/bin/wc -l) -gt 2" | |
} | |
file { "/usr/local/bin/run-backups.sh": | |
mode => 755, | |
owner => "root", | |
group => "root", | |
require => [ | |
Package["duplicity"], | |
Package["gnupg"], | |
Package["python-boto"], | |
Package["mongodb-10gen"], | |
Exec["import-keys"], | |
Exec["import-trust"] | |
], | |
content => template("s3-backups/run-backups.sh") | |
} | |
file { "/root/s3-backup-privkey.key": | |
mode => 600, | |
owner => "root", | |
group => "root", | |
require => Package["gnupg"], | |
content => template("s3-backups/s3-backup-privkey.key") | |
} | |
file { "/root/s3-backup-pubkey.key": | |
mode => 600, | |
owner => "root", | |
group => "root", | |
require => Package["gnupg"], | |
content => template("s3-backups/s3-backup-pubkey.key") | |
} | |
file { "/root/s3-backup-key-ownertrust": | |
mode => 600, | |
owner => "root", | |
group => "root", | |
require => [ | |
Package["gnupg"], | |
Exec["import-keys"] | |
], | |
content => template("s3-backups/s3-backup-key-ownertrust") | |
} | |
cron { "s3-backup": | |
command => "/usr/local/bin/run-backups.sh", | |
user => "root", | |
ensure => "present", | |
require => File["/usr/local/bin/run-backups.sh"], | |
minute => '00', | |
hour => '*', | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment