嘗試在Rackspace站點上使用Perl cron作業備份我們的數據庫。用於在Rackspace上備份數據庫的Perl腳本
給出了Rackspace公司的例子:
#!/bin/sh
mysqldump -h DB_HOST -u DB_USER -p'DB_PASSWORD' DB_NAME > YOUR_WEB_ROOT/db_backup.sql
gzip -f YOUR_WEB_ROOT/db_backup.sql
這工作正常,但我想投入的文件名時間戳。我有這段代碼生成時間戳:
use strict;
use warnings;
use DateTime;
my $dt = DateTime->now;
my $date = $dt->ymd;
my $time = $dt->hms;
my $file = "****.com/db_backups/db_backup - $date $time.sql";
print $file;
最終產品:
#!/bin/sh
use strict;
use warnings;
use DateTime;
my $dt = DateTime->now;
my $date = $dt->ymd;
my $time = $dt->hms;
my $file = "****.com/db_backups/db_backup - $date $time.sql";
print $file;
mysqldump -h hosturl -u username -p'password' database > $file;
gzip -f $file;
當它運行時我得到這些錯誤。
/mnt/stor09-wc1-ord1/758094/****.com/backup.sh: line 2: use: command not found
/mnt/stor09-wc1-ord1/758094/****.com/backup.sh: line 3: use: command not found
/mnt/stor09-wc1-ord1/758094/****.com/backup.sh: line 4: use: command not found
/mnt/stor09-wc1-ord1/758094/****.com/backup.sh: line 5: my: command not found
/mnt/stor09-wc1-ord1/758094/****.com/backup.sh: line 6: my: command not found
/mnt/stor09-wc1-ord1/758094/****.com/backup.sh: line 7: my: command not found
/mnt/stor09-wc1-ord1/758094/****.com/backup.sh: line 8: my: command not found
/mnt/stor09-wc1-ord1/758094/****.com/backup.sh: line 9: print: command not found
/mnt/stor09-wc1-ord1/758094/****.com/backup.sh: line 10: $file: ambiguous redirect