Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: add-foreign-ke…
Fetching contributors…

Cannot retrieve contributors at this time

executable file 63 lines (50 sloc) 1.395 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
#!/usr/bin/perl

use strict;
use warnings;

use Getopt::Long;
use VegGuide::Config;

exit 0
    unless VegGuide::Config->IsProduction()
        && !VegGuide::Config->IsTest();

my $verbose;
my @hosts;
my $dump = 1;

GetOptions(
    'verbose' => \$verbose,
    'host=s@' => \@hosts,
    'dump!' => \$dump,
);

@hosts = qw( urth.org li205-70.members.linode.com )
    unless @hosts;

# Should be run as me (autarch) on the vegguide.org box. No need to
# run as root.

if ($dump) {
    print "Dumping database\n\n" if $verbose;

    system(
        qw( mysqldump -u root RegVeg --ignore-table RegVeg.Session -r /home/autarch/RegVeg.sql )
    ) and die 'Cannot execute mysqldump';
}

for my $host (@hosts) {
    print "Rsyncing to $host\n\n";

    for my $source (
        qw(
/etc
/var/lib/vegguide/entry-images
/var/lib/vegguide/user-images
/var/lib/vegguide/skin-images
/home/autarch/RegVeg.sql
/var/lib/mailman/archives
/var/lib/mailman/lists )
        ) {

        my @v = $verbose ? '-v' : ();
        system(
            'rsync',
            @v,
            '-e', 'ssh -i /home/autarch/.ssh/id_rsa.backups',
            '-r', '--links',
            $source,
            'autarch@' . $host . ':/home/autarch/backup/vegguide.org/'
        ) and die "Cannot rsync $source to $host";
    }
}

print "vg-backup completed successfully\n\n";
Something went wrong with that request. Please try again.