title: Perl script to backup database on Rackspace
body: <p>Trying to backup our database using Perl cron job on Rackspace Sites.</p>
  
  <p>Rackspace gives an example of:</p>
  
  <pre><code>#!/bin/sh
  mysqldump -h DB_HOST -u DB_USER -p'DB_PASSWORD' DB_NAME &gt; YOUR_WEB_ROOT/db_backup.sql
  gzip -f YOUR_WEB_ROOT/db_backup.sql
  </code></pre>
  
  <p>That works fine but I want a timestamp put into the filename. I have this bit of code that generates the timestamp:</p>
  
  <pre><code>use strict;
  use warnings;
  use DateTime;
  
  my $dt   = DateTime-&gt;now;
  my $date = $dt-&gt;ymd;
  my $time = $dt-&gt;hms;
  
  my $file = "****.com/db_backups/db_backup - $date $time.sql";
  
  print $file;
  </code></pre>
  
  <p>The final Product:</p>
  
  <pre><code>#!/bin/sh
  use strict;
  use warnings;
  use DateTime;
  
  my $dt   = DateTime-&gt;now;
  my $date = $dt-&gt;ymd;
  my $time = $dt-&gt;hms;
  
  my $file = "****.com/db_backups/db_backup - $date $time.sql";
  
  print $file;
  
  mysqldump -h hosturl -u username -p'password' database &gt; $file;
  gzip -f $file;
  </code></pre>
  
  <p>When it runs I get these errors.</p>
  
  <pre><code>/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
  </code></pre>