Re: BackUp ZC [Support Thread]
Thanks Skip.
I asked the question because I changed
Code:
$file_name = $_SERVER['HTTP_HOST'].'_'.date("mdY-Hi"); // Create File Name
to
Code:
$file_name = $_SERVER['HTTP_HOST'].'_'.date("dmY-Hi"); // Create File Name
but the file names still have a mdy format.
Have I missed something here??
Re: BackUp ZC [Support Thread]
Quote:
Originally Posted by
pewe
Thanks Skip.
I asked the question because I changed
Code:
$file_name = $_SERVER['HTTP_HOST'].'_'.date("mdY-Hi"); // Create File Name
to
Code:
$file_name = $_SERVER['HTTP_HOST'].'_'.date("dmY-Hi"); // Create File Name
but the file names still have a mdy format.
Have I missed something here??
It's OK - the date has changed, but only on the website file and I was looking at the .sql file.
I had to change the other two lines to alter the format of the sql file name.
I have one other question though.
I would like to change the 'time' so it does not use the time on the server but matches the time zone I am in. The server is using a US timezone but I am in the UK (London/Europe).
Is this possible? - if so, how?
Thanks
Re: BackUp ZC [Support Thread]
Because the script is using the server time it would be to much to change the code.
Some hosts allow you to change the server time zone GMT +- #, you might want to check.
Skip
Re: BackUp ZC [Support Thread]
Quote:
Originally Posted by
skipwater
Because the script is using the server time it would be to much to change the code.
Some hosts allow you to change the server time zone GMT +- #, you might want to check.
Skip
Thanks Skip.
What I found strange was that when I look at the backup files created using Filezilla or the Control Panel File Manager, the date of creation is shown in GMT, but the file name is generated using GMT +6 (ie time zone of the server).
However adding this
Code:
date_default_timezone_set('Europe/London');
like this
Code:
// Grab a large chunk of memory
// If your server allows this adjustment then adjust to meet your needs.
// ***********************************************************************
// ini_set("memory_limit","128M");
// ini_set("memory_limit","192M");
// ini_set("memory_limit","256M");
ini_set("memory_limit","512M"); // default
// ini_set("memory_limit","768M");
// ini_set("memory_limit","1000M");
date_default_timezone_set('Europe/London');
appears to have done the trick.
Re: BackUp ZC [Support Thread]
Quote:
Originally Posted by
pewe
It's OK - the date has changed, but only on the website file and I was looking at the .sql file.
I had to change the other two lines to alter the format of the sql file name.
I have one other question though.
I would like to change the 'time' so it does not use the time on the server but matches the time zone I am in. The server is using a US timezone but I am in the UK (London/Europe).
Is this possible? - if so, how?
Thanks
One way, before presenting the date formatting, I would create a date variable that is equal to the current date, then would shift the date timezone to the desired timezone, then would as coded display the date but have the date variable following in the presentation of the date add a comma, then the variable for the new date. The below hasn't been tested, but generally pieced together from php manual date/time related functions.
So could insert some of the below with the applicable statement:
Code:
$newDate = new time();
$newDate->setTimezone(new DateTimeZone('London/Europe'));
//Assuming London/Europe is the correct format.
$file_name = $_SERVER['HTTP_HOST'].'_'.date("dmY-Hi", $newDate); // Create File Name
There appears to be other ways to do it as well, such as using date offset like functions, but ideally you would have somewhere a variable set to represent your local timezone and that would be fed into the function above instead of hard coding it, unless the standard becomes all dates will be in GMT and then there is no question
Re: BackUp ZC [Support Thread]
Quote:
Originally Posted by
pewe
Thanks Skip.
What I found strange was that when I look at the backup files created using Filezilla or the Control Panel File Manager, the date of creation is shown in GMT, but the file name is generated using GMT +6 (ie time zone of the server).
However adding this
Code:
date_default_timezone_set('Europe/London');
like this
Code:
// Grab a large chunk of memory
// If your server allows this adjustment then adjust to meet your needs.
// ***********************************************************************
// ini_set("memory_limit","128M");
// ini_set("memory_limit","192M");
// ini_set("memory_limit","256M");
ini_set("memory_limit","512M"); // default
// ini_set("memory_limit","768M");
// ini_set("memory_limit","1000M");
date_default_timezone_set('Europe/London');
appears to have done the trick.
Of course, something like that fix is the preferred method. :)
Re: BackUp ZC [Support Thread]
Sorry - me again.
The file name is created using
Code:
$file_name = $_SERVER['HTTP_HOST'].'_'.date("d-m-Y_H:i");
This creates a file 'domain.com_10-01-2014_17:45.zip'
How could I change this so that the file includes the 'store name' in place of or as well as the domain name in front of the date/time.
Thanks
Re: BackUp ZC [Support Thread]
Quote:
Originally Posted by
pewe
Sorry - me again.
The file name is created using
Code:
$file_name = $_SERVER['HTTP_HOST'].'_'.date("d-m-Y_H:i");
This creates a file 'domain.com_10-01-2014_17:45.zip'
How could I change this so that the file includes the 'store name' in place of or as well as the domain name in front of the date/time.
Thanks
Wherever desired add in the constant STORE_NAME, though not sure what the correct variable name is if running a multi-store from a single database.
Code:
$file_name = $_SERVER['HTTP_HOST'].'_'.STORE_NAME.'_'.date("d-m-Y_H:i");
For example, but would also be a good idea to do some string formatting on it to remove spaces, and do something with apostrophes and quotes, etc... Not sure off top of my head, which function(s) would be best to use at this point, but I'm sure ZC has some built in to handle filenames.
Re: BackUp ZC [Support Thread]
Quote:
Originally Posted by
mc12345678
Wherever desired add in the constant STORE_NAME, though not sure what the correct variable name is if running a multi-store from a single database.
Code:
$file_name = $_SERVER['HTTP_HOST'].'_'.STORE_NAME.'_'.date("d-m-Y_H:i");
For example, but would also be a good idea to do some string formatting on it to remove spaces, and do something with apostrophes and quotes, etc... Not sure off top of my head, which function(s) would be best to use at this point, but I'm sure ZC has some built in to handle filenames.
Thanks - appreciated.
Your suggested code did the trick, including working with spaces. Will check out other things like apostrophes etc later.
Re: BackUp ZC [Support Thread]
Hi again.
I have now done some tests and find I have a issue.
When trying to extract a downloaded full web site backup there were problems with 'corrupt archive' messages.
I have now determined that the cause of the problem is that within the 'images' directory are subdirectories with periods in the name - for example '1.Tools' or '2.Accessories'.
So the period in the directory name seems to cause a problem.
HOWEVER:
This problem does not occur when I use the compression routine in my control panel to zip the same directories, nor does it appear with another backup script I have that also compresses the directories/files in ZC (this is not a ZC plugin but does a similar job).
Anyone any suggestions as to how I can rectify this issue.
Thanks