Thứ Bảy, 6 tháng 4, 2013

cron - Perl script to backup database on Rackspace

Attempting to backup our database utilizing Perl cron task on Rackspace Web sites.

Rackspace presents an case in point of:

#!/bin/sh mysqldump -h DB_HOST -u DB_Consumer -p'DB_PASSWORD' DB_Identify > YOUR_World wide web_ROOT/db_backup.sql gzip -f YOUR_Net_ROOT/db_backup.sql

That works fine but I want a timestamp put into the filename. I have this bit of code that generates the timestamp:

use stringent use warnings use DateTime my $dt = DateTime->now my $date = $dt->ymd my $time = $dt->hms my $file = "****.com/db_backups/db_backup - $day $time.sql" print $file

The final Solution:

#!/bin/sh use stringent use warnings use DateTime my $dt = DateTime->now my $day = ism adamo prologue seat bright $dt->ymd my $time = $dt->hms my $file = "****.com/db_backups/db_backup - $day $time.sql" print $file mysqldump -h hosturl -u username -p'password' databases > $file gzip -f $file

When it operates I get these mistakes.

/mnt/stor09-wc1-ord1/758094/****.com/backup.sh: line 2: use: command not found /mnt/stor09-wc1-ord1/758094/****.com/backup.sh: line three: use: command not identified /mnt/stor09-wc1-ord1/758094/****.com/backup.sh: line 4: use: command not located /mnt/stor09-wc1-ord1/758094/****.com/backup.sh: line 5: my: command not identified /mnt/stor09-wc1-ord1/758094/****.com/backup.sh: line six: my: command not identified /mnt/stor09-wc1-ord1/758094/****.com/backup.sh: line 7: my: command not identified /mnt/stor09-wc1-ord1/758094/****.com/backup.sh: line 8: my: command not discovered /mnt/stor09-wc1-ord1/758094/****.com/backup.sh: line nine: print: command not located /mnt/stor09-wc1-ord1/758094/****.com/backup.sh: line 10: $file: ambiguous redirect

Không có nhận xét nào:

Đăng nhận xét