Created
November 27, 2015 07:24
-
-
Save MattHealy/e25a68e8eb75c1012b12 to your computer and use it in GitHub Desktop.
Simple Perl script to mirror a website to Amazon S3
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
#!/usr/bin/perl | |
($sec,$min,$hour,$mday,$mon,$year,$nothing,$nothing,$nothing)=localtime(time); | |
if ($mon<12) { | |
$mon++; | |
} | |
if ($pmon<12) { | |
$pmon++; | |
} | |
if ($mon<10) { $mon="0$mon"; } | |
if ($mday<10) { $mday="0$mday"; } | |
$year+=1900; | |
$timestamp = "${year}${mon}${mday}"; | |
#-------------------------------------------------------------------------- | |
# MySQL | |
system("/usr/bin/mysqldump -A > /tmp/maad-$timestamp.sql"); | |
system("/usr/bin/gzip /tmp/maad-$timestamp.sql"); | |
#-------------------------------------------------------------------------- | |
print "Beginning S3 Sync\n"; | |
system("/usr/bin/aws s3 mv /tmp/maad-$timestamp.sql.gz s3://maad-backup/mysql/"); | |
system("/usr/bin/aws s3 sync --no-follow-symlinks --delete /usr/local/sbin/ s3://maad-backup/sbin"); | |
system("/usr/bin/aws s3 sync --no-follow-symlinks --delete /var/spool/cron/ s3://maad-backup/cron"); | |
system("/usr/bin/aws s3 sync --no-follow-symlinks --delete /var/www/cgi-bin/ s3://maad-backup/cgi-bin"); | |
system("/usr/bin/aws s3 sync --no-follow-symlinks --delete /var/www/html/ s3://maad-backup/html"); | |
print "Backup complete\n"; | |
exit; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment