Thursday, 31 October 2013
Monday, 14 October 2013
Perl script for documents backup
#!/usr/bin/perl
# Configuration params
$backup_dir = '/home/username/public_html';
$file_prefix = 'doc_backup_';
# Get the timestamp for today
$date = `date "+%Y%m%d"`;
chomp($date);
chdir('/home/username/backup/doc_backup') ;
`tar -cv -f $file_prefix$date.tar $backup_dir`;
`bzip2 $file_prefix$date.tar`;
# Below line is used to remove the backups older than 5 days to free up the server space
system("find . -mtime +5 -type f -name 'doc_backup_*' -exec rm {} \\;");
# Configuration params
$backup_dir = '/home/username/public_html';
$file_prefix = 'doc_backup_';
# Get the timestamp for today
$date = `date "+%Y%m%d"`;
chomp($date);
chdir('/home/username/backup/doc_backup') ;
`tar -cv -f $file_prefix$date.tar $backup_dir`;
`bzip2 $file_prefix$date.tar`;
# Below line is used to remove the backups older than 5 days to free up the server space
system("find . -mtime +5 -type f -name 'doc_backup_*' -exec rm {} \\;");
Perl script for Database backup
#Configuration params
$host = 'localhost';
$user = 'username';
$pass = 'password';
$database = 'dbname';
$backup_dir = '/home/username/backup/db_backup';
$file_prefix = 'database_backup_';
# Get the timestamp for today
$date = `date "+%Y%m%d"`;
chomp($date);
`mysqldump --host=$host --user=$user --pass=$pass $database | bzip2 -c > $backup_dir/$file_prefix$database$date.sql.bz2`;
Friday, 4 October 2013
Subscribe to:
Posts (Atom)