Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: makebackup

by Jaap (Curate)
on Mar 29, 2005 at 14:21 UTC ( [id://443135]=note: print w/replies, xml ) Need Help??


in reply to makebackup

Allow me to clean it up a bit:
  • use strict
  • use multi-argument system calls for safety
  • don't rely on $ENV{'PATH'}
  • Why use Time::localtime?
#!/usr/bin/perl use strict; use warnings; $ENV{'PATH'} = ''; my $zipExec = '/usr/bin/zip'; my $chownExec = '/bin/chown'; #----------------GET TIME -------------------------- sub now { my @time = (localtime())[3 .. 5]; return sprintf ("%02d-%02d-%04d", $time[0], $time[1] + 1, $time[2] + + 1900); } my $g = now(); print "\nThe Time NOW:\t $g\n"; print "\n-------ZIPPING DATABASE-------\n"; my $zipdbname = "dbbackup$g"; my $zipexnname = "ExnCorp$g"; system($zipExec, '-r', $zipdbname, '/var/lib/mysql/*'); print "\n-------DATABASE ZIPPED-------\n"; print "\n-------ZIPPING EXN-------\n"; system($zipExec, '-r', $zipexnname, '/var/www/html/ExnCorp/*'); print "\n-------EXN ZIPPED-------\n"; $zipdbname .= '.zip'; $zipexnname .= '.zip'; system($chownExec, 'dev:dev', $zipdbname"; system($chownExec, 'devftp:devftp', $zipexnname";
Warning: code is untested.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://443135]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2024-04-25 06:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found