• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1035
  • Last Modified:

PHP copy error

Hello all!

I am attempting to write myself a quick and dirty backup script that will run in crontab eventually.  The directory and tar archive are created properly, however, once they are, the tar is not copied successfully.  The error I receive is:

Warning: copy(/home/dbrennan/backups/06-06-2006/): failed to open stream: Is a directory in /var/www/html/buffalotraders/test/dan/backup_dan.php on line 17


i don't get why this error is occurring.

My code is below.  Thanks in advance for your help!

------------ CODE -------------

<?php
$dater = date(m."-".d."-".Y);

if(!file_exists("/home/dbrennan/backups/".$dater))
{
   mkdir("/home/dbrennan/backups/".$dater);
}

if(!file_exists("/buffalotraders/test/dan/".$dater.".tar"))
{
   $cmd = "tar -cvvf ".$dater.".tar /buffalotraders/test/dan/";
   $res = shell_exec($cmd);
}

if(file_exists("/buffalotraders/test/dan/".$dater.".tar"))
{
   copy("/buffalotraders/test/dan/".$dater.".tar","/home/dbrennan/backups/".$dater."/");
}
%>

---------- END CODE ----------
0
flow79
Asked:
flow79
  • 2
1 Solution
 
neesterCommented:
change:

copy("/buffalotraders/test/dan/".$dater.".tar","/home/dbrennan/backups/".$dater."/");

to

copy("/buffalotraders/test/dan/".$dater.".tar","/home/dbrennan/backups/".$dater."tar");
0
 
neesterCommented:
copy("/buffalotraders/test/dan/".$dater.".tar","/home/dbrennan/backups/".$dater.".tar");
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now