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 ----------
LVL 13
flow79Asked:
Who is Participating?
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.