Jump to content

Auto backup?


Cory94bailly

Recommended Posts

My code:

 

<?
$date = date('m-d-Y');
mkdir("backups/$date/", 0700);
mkdir("backups/$date/fcs/", 0700);
mkdir("backups/$date/fcs/admin", 0700);
mkdir("backups/$date/fcs/images", 0700);
mkdir("backups/$date/fcs/includes", 0700);
mkdir("backups/$date/fcs/uploaded", 0700);
copy('fcs',"backups/$date/fcs/");
copy('fcs/admin', "backups/$date/fcs/admin/");
copy('fcs/images', "backups/$date/fcs/images/");
copy('fcs/includes', "backups/$date/fcs/includes/");
copy('fcs/uploaded', "backups/$date/fcs/uploaded/");
echo "Task done successfully!";
?>

 

 

But I am getting things like:

 

Warning: copy() [function.copy]: The first argument to copy() function cannot be a directory in /home/content/m/a/r/markbailly/html/backupfcs.php on line 10

Warning: copy() [function.copy]: The first argument to copy() function cannot be a directory in /home/content/m/a/r/markbailly/html/backupfcs.php on line 11

Warning: copy() [function.copy]: The first argument to copy() function cannot be a directory in /home/content/m/a/r/markbailly/html/backupfcs.php on line 12

Warning: copy() [function.copy]: The first argument to copy() function cannot be a directory in /home/content/m/a/r/markbailly/html/backupfcs.php on line 13

Warning: copy() [function.copy]: The first argument to copy() function cannot be a directory in /home/content/m/a/r/markbailly/html/backupfcs.php on line 14

 

 

How can I get it to copy every file inside the directory to a new one?

 

Thanks guys.

Link to comment
https://forums.phpfreaks.com/topic/107681-auto-backup/
Share on other sites

try something like copy("/path/to/files/*", "/path/to/archived/files/")

 

Warning: copy(fcs/*) [function.copy]: failed to open stream: No such file or directory in /home/content/m/a/r/markbailly/html/backupfcs.php on line 10

 

 

 

 

List every file and copy it inside a loop...

http://php.net/opendir

http://php.net/glob

 

 

One of those should help.

 

Hmm, I'll need help with that..

Link to comment
https://forums.phpfreaks.com/topic/107681-auto-backup/#findComment-552047
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.