The FreeBSD Diary

The FreeBSD Diary (TM)

Providing practical examples since 1998

If you buy from Amazon USA, please support us by using this link.
[ HOME | TOPICS | INDEX | WEB RESOURCES | BOOKS | CONTRIBUTE | SEARCH | FEEDBACK | FAQ | FORUMS ]
Scripts / handy tips
 New Topic  |  Go to Top  |  Go to Topic  |  Search  |  Log In   Previous Message  |  Next Message 
 Simple backup script in perl...
Author: Erin 
Date:   06-08-04 16:28

This simple script uses "dump" to backup a hard drive to another hard drive. It will do a full backup on Sunday and an incremental every other day of the week. All this and it runs the dump file through gzip to compress it.


-----------------------------

#!/usr/bin/perl -w

use strict;

my @FS = ('/', '/home', '/tmp', '/usr', '/var');
my $day = &day;
my $type;

if ($day eq "sunday") {

	$type = "0"

} else {

	$type = "1"

}


foreach (@FS) {

        my $name = $_;

        if ($name eq '/') {
                $name = '/root';
        }

        $name =~ s|^/||g;

        system("/sbin/dump -$type -auf - $_ | gzip -q > /backup/$day/$name.dump.gz");

}

sub day {

        my @days = ('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday');

        my (undef, undef, undef, undef, undef, undef, $wday, undef, undef) = localtime(time);

        return("$days[$wday]");

};

exit(1);



 Reply To This Message  |  Forum List  |  Flat View   Newer Topic  |  Older Topic 

 Topics Author  Date
 Simple backup script in perl...   new
Erin 06-08-04 16:28 
 Re: Simple backup script in perl...   new
Jeroen Steggink 17-09-04 12:59 
 Re: Simple backup script in perl...   new
Erin 17-09-04 20:56 
 Re: Simple backup script in perl...   new
Erin 17-09-04 21:09 


 Forum List  |  Need a Login? Register Here 
 User Login
 User Name:
 Password:
 Remember my login:
   
 Forgot Your Password?
Enter your email address or user name below and a new password will be sent to the email address associated with your profile.
How to get the most out of the forum

phorum.org