Jump to content

[SOLVED] Backing Up To A folder With The Day's Date?


Cory94bailly

Recommended Posts

Here's my code:

 

<?
$date = "date('d-m-Y')"
//unlink ('backups/fcs/index.php');
//unlink ('backups/fcs/aboutus.php');
//unlink ('backups/fcs/login.php');
//unlink ('backups/fcs/services.php');
//unlink ('backups/fcs/team.php');
copy('fcs/index.php','backups/fcs/$date/index.php');
copy('fcs/aboutus.php','backups/fcs/$date/aboutus.php');
copy('fcs/login.php','backups/fcs/$date/login.php');
copy('fcs/services.php','backups/fcs/$date/services.php');
copy('fcs/team.php','backups/fcs/$date/team.php');
if (copy)
echo "Task done successfully!";
else 
echo "Unsuccessful!";
?>

 

(Didn't bother removing the actual file names..)

 

Now how would I get this to work?

 

Well I just realized that I never created the folder of the date, is that my problem? How do I do that..?

 

And here's my error:

 

Parse error: syntax error, unexpected T_STRING in /home/content/m/a/r/markbailly/html/backupfcs.php on line 8

mkdir is your friend.

 

http://au.php.net/mkdir

 

<?php
mkdir("backups/fcs/$date/", 0700);
?> 

 

Parse error: syntax error, unexpected T_STRING in /home/content/m/a/r/markbailly/html/backupfcs.php on line 3

 

 

<?
$date = "date('d-m-Y')"
mkdir ('$date');
//unlink ('backups/fcs/index.php');
//unlink ('backups/fcs/aboutus.php');
//unlink ('backups/fcs/login.php');
//unlink ('backups/fcs/services.php');
//unlink ('backups/fcs/team.php');
copy('fcs/index.php','backups/fcs/$date/index.php');
copy('fcs/aboutus.php','backups/fcs/$date/aboutus.php');
copy('fcs/login.php','backups/fcs/$date/login.php');
copy('fcs/services.php','backups/fcs/$date/services.php');
copy('fcs/team.php','backups/fcs/$date/team.php');
if (copy)
echo "Task done successfully!";
else 
echo "Unsuccessful!";
?>

 

Edit:

 

Changed it to your code and same thing..

$date = "date('d-m-Y')";

 

missing the ;

 

Ohhh! That helped that much.. :D

 

Next:

 

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

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

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

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

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

 

<?
$date = "date('d-m-Y')";
mkdir("backups/fcs/$date/", 0700);
//unlink ('backups/fcs/index.php');
//unlink ('backups/fcs/aboutus.php');
//unlink ('backups/fcs/login.php');
//unlink ('backups/fcs/services.php');
//unlink ('backups/fcs/team.php');
copy('fcs/index.php','backups/fcs/$date/index.php');
copy('fcs/aboutus.php','backups/fcs/$date/aboutus.php');
copy('fcs/login.php','backups/fcs/$date/login.php');
copy('fcs/services.php','backups/fcs/$date/services.php');
copy('fcs/team.php','backups/fcs/$date/team.php');
if (copy)
echo "Task done successfully!";
else 
echo "Unsuccessful!";
?>

It's telling you whats wrong.

 

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

 

It cant find backups/fcs/$date/index.php.

 

edit: ah, that would be the problem (date('d-m-Y'))

 

You might want to change

$date = "date('d-m-Y')";

to

$date = date('d-m-Y');

otherwise you're not calling the function but making a string with that content.

 

Furthermore,

if (copy)

won't work.

 

That date thing fixed part of it.. It now named a folder with the actual day's date...

 

But it's still trying to physically save to the folder $date..

 

How do I fix that part? This is the error:

 

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

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

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

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

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

Oh yes. You'll also need to change

'backups/fcs/$date/index.php'

and similar strings to use double quotes instead. Variable interpolation (i.e. replacement of the variables' values within strings) will only work with strings that are using either the HEREDOC syntax or using double quotes. Single quoted strings will be used verbatim.

Oh yes. You'll also need to change

'backups/fcs/$date/index.php'

and similar strings to use double quotes instead. Variable interpolation (i.e. replacement of the variables' values within strings) will only work with strings that are using either the HEREDOC syntax or using double quotes. Single quoted strings will be used verbatim.

 

Soo.. I do......? What?

Warning: Wrong parameter count for copy() in /home/content/m/a/r/markbailly/html/backupfcs.php on line 5

Warning: Wrong parameter count for copy() in /home/content/m/a/r/markbailly/html/backupfcs.php on line 6

Warning: Wrong parameter count for copy() in /home/content/m/a/r/markbailly/html/backupfcs.php on line 7

Warning: Wrong parameter count for copy() in /home/content/m/a/r/markbailly/html/backupfcs.php on line 8

Warning: Wrong parameter count for copy() in /home/content/m/a/r/markbailly/html/backupfcs.php on line 9

 

<?
$date = date('d-m-Y');
mkdir("backups/$date/", 0700);
mkdir("backups/$date/fcs/", 0700);
copy("fcs/index.php','backups/$date/fcs/index.php");
copy("fcs/aboutus.php','backups/$date/fcs/aboutus.php");
copy("fcs/login.php','backups/$date/fcs/login.php");
copy("fcs/services.php','backups/$date/fcs/services.php");
copy("fcs/team.php','backups/$date/fcs/team.php");
echo "Task done successfully!";
?>

 

Wait.. my mistake..

 

Hold on.

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.