Jump to content
spooks

[Contribution] Website Backup - Create zipped copy of all site files

Recommended Posts

@@missery

 

The next version (out soon) will have more checks in place to catch issues,

but one thing to test, in your admin/configure.php does the definition for DIR_FS_DOCUMENT_ROOT have a trailing / like it should ?

Hi Sam,

no there is no trailing / it is just DIR_FS_DOCUMENT_ROOT

define('DIR_FS_ADMIN', DIR_FS_DOCUMENT_ROOT . ESF_ADMIN);

define('DIR_FS_CATALOG', DIR_FS_DOCUMENT_ROOT . ESF_CATALOG);

 

regards

Share this post


Link to post
Share on other sites

Uploaded New Version 1.1

  • Added GZipping option to widen server compatibility.
  • Added test for existence of ZipArchive class.
  • Modified headers to widen compatibility.
  • Added additional testing for configuration variables.
  • Added inclusion of zero byte files in backup files.
  • Added inclusion of empty directories in backup files.
  • Removed Content Length on streaming (for now) as it seems to cause issues.
  • Added session check controls, see settings.
  • Moved functions to separate file.

 

Please note the GZipping option is currently experimental, please report results.


Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Share this post


Link to post
Share on other sites

Hello

I installed the new version and it no longer works.

I have not a value for size of your site and compressed size.

Website size: 0 Bytes Estimated compressed file size: 0 Bytes Containing 0 folders with 0 Files. And when I backup, the file is empty.

With the old version it was OK

Website size: 64.27 MB Estimated compressed file size: 43.7 MB Containing 1799 folders with 5798 Files.

And when I backup, the file is ok with the backup of all my files.

 

Have you an idea?

Thank's for this very great addon.

Francois

Share this post


Link to post
Share on other sites

@@spooks Hi again, I downloaded the latest version and was able to use the gzip method. Now I can't seem to be able to unarchive the files. I use 7zip and get "cannot open this file as archive" when I try to extract the .tar. My server is centOS and my home pc is winXP. Maybe it's just a 7zip issue? I have never run into it before but you never know...

 

Ok, Now .zip has started working for me. Wow, maybe I'm just losing my mind (w00t)

Edited by mattjt83

Matt

Share this post


Link to post
Share on other sites

Sam, thank you for the update. I have tested using all three methods and this is the result:

 

Backup was always created and saved successfully.

 

$guess = -10; (I hope that this is not causing any problems?)

 

Memory Mode GZipping

 

PHP Version: 5.2.9 Method: Tar Server OS: Linux

 

Website size: 143.15 MB Estimated compressed file size: 83.03 MB Containing 343 folders with 5484 Files. Downloaded file size 28,913 KB

 

WinRAR and Opus Directory Error message while unpacking: The archive is corrupt. I was however able to unpack it with 7zip.

 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

File Mode Zipping

 

Website size: 143.15 MB Estimated compressed file size: 83.03 MB Containing 343 folders with 5484 Files. Downloaded file size 31,034 KB

 

No errors while unpacking using WinRAR or 7zip.

 

There is a home folder (with folder structure) created within backup containing no files as well as Website-Backup folder containing all folders and files.

 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

Memory Mode Zipping

 

Website size: 143.15 MB Estimated compressed file size: 83.03 MB Containing 343 folders with 5484 Files. Downloaded file size 31,515 KB

 

I am able to unpack using WinRAR or 7zip, however 7zip and WinRAR keep asking to confirm file replace and throwing errors. These errors look in 7zip as follows:

ERROR: Can not delete output file C:\Data\Destinatin backup folder\My-Website-Backup\admin\includes\local

334 lines of errors in total, however the unpacked backup seems to look OK but it's rather hard to confirm for sure without uploading back to server I guess. Always suspicious to see errors.

 

There is only Website-Backup folder containing all folders and files, no home folder.

 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

That's all I was able to find out at the moment. For me, the File Mode Zipping is the most reliable method at the moment.


Absinthe Original Liquor Store

Share this post


Link to post
Share on other sites

@@francois21

 

Are you saying with the current the estimate is 0 but the backup is fine?

 

Please post the setting for define('DIR_FS_DOCUMENT_ROOT', '/xxx/'); in your admin/includes/configure.php and Server OS


Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Share this post


Link to post
Share on other sites

@@mattjt83

 

The issue with the gzip method is the creation of the tar, it falls down with some directory structures, thats an issue I need to address.


Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Share this post


Link to post
Share on other sites

@mr_absinthe

 

You wont do any harm changing the guess especially as Content-Length is removed for now.

 

GZipping yes some extractors are more pedantic over file headers than others, its in progress, but remember windows throws much of that info their worried about away!!

 

There is a home folder (with folder structure) created within backup containing no files as well as Website-Backup folder containing all folders and files.

 

Its the belt and braises method ensuring the folders are created, but your structure has caused a duplication, but I should have allowed :blush:

 

backup_website.php line 87, replace:

 

elseif (@@IS_dir($file)) if ($zip->addEmptyDir($file) === false) $wok = false;

 

with:

 

elseif (@@IS_dir($file)) if ($zip->addEmptyDir($name) === false) $wok = false;

 

 

Your just changing $file to $name in the code, useless forum changes what I put!! (w00t)

Edited by spooks

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Share this post


Link to post
Share on other sites

i have got this working with the modifications you mentioned to me in my previous posts, however there are some issues

 

File Mode Zipping:

this download the backup fine but it downloads it 2 times in the rar file one backup called "home" the other "mywebsitesname-backup"

 

Memory Mode Zipping:

This give me a corrupt message when i try to open the rar file.

 

i have now unistalled it for now as i cant use having as i have a security risk , as i have this setting to true to get it to wok ($no_session = TRUE )

Share this post


Link to post
Share on other sites

Its the belt and braises method ensuring the folders are created, but your structure has caused a duplication, but I should have allowed :blush:

 

backup_website.php line 87, replace:

 

elseif (@@IS_dir($file)) if ($zip->addEmptyDir($file) === false) $wok = false;

 

with:

 

elseif (@@IS_dir($file)) if ($zip->addEmptyDir($name) === false) $wok = false;

 

 

Your just changing $file to $name in the code, useless forum changes what I put!! (w00t)

 

I can confirm that the File Mode Zipping method is fine now, thank you! :thumbsup:


Absinthe Original Liquor Store

Share this post


Link to post
Share on other sites
@francois21

 

Are you saying with the current the estimate is 0 but the backup is fine?

 

Please post the setting for define('DIR_FS_DOCUMENT_ROOT', '/xxx/'); in your admin/includes/configure.php and Server OS

 

Thank's for your response.

 

If I put the old file "website_backup.php" in the directory admin , all work fine, if I put the new file, I have no errors but it does not work.

I made the update from the old version to the new v1.1 with all the new files as shown in "Sam's Website Backup V1.1. ."

 

with the current the estimate is 0 ====> Yes

but the backup is fine====> No I have no backup

 

With old version all is fine estimate and backup

 

define('DIR_FS_DOCUMENT_ROOT', 'C:/wamp/www/01-boutic_rc231_en_dev/');

I am in local test with wampserver, my os is windows7

Francois

Edited by francois21

Share this post


Link to post
Share on other sites

@@francois21

 

Its your wamp configuration or the way your accessing files, its not quite correct, you should configure like a real server.

 

If you have the menu, just select apache->httpd.conf and edit DocumentRoot so its DocumentRoot "c:/wamp/www/"

 

or if you don't have the menu its in wamp/bin/apache/Apachxxx/conf/httpd.conf

 

then you access the site with http://localhost/ and your configure files have define('DIR_FS_DOCUMENT_ROOT', '/wamp/www/');

 

You can also setup aliases if you wish to run multiple sites on the server, though you can also do that just by using a folder for each site in the wamp root.


Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Share this post


Link to post
Share on other sites

@@missery

 

Your issue is due to your renaming of your admin sessions, if you edited the line

$session_name = 'admin';

to reflect what you changed it to you would have no problem, look in your admin->login.php if you don't remember what's set.


Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Share this post


Link to post
Share on other sites

@@missery

 

Your issue is due to your renaming of your admin sessions, if you edited the line

$session_name = 'admin';

to reflect what you changed it to you would have no problem, look in your admin->login.php if you don't remember what's set.

 

@@spooks i have changed the admin session name to the same name as my renamed adin folder as i do not have an admin->login.php file, i presume this was removed for security purposes. i presume its the same as my admin folder but i am unsure !! and i am now getting redirected to the admin index.php,

 

regards

Edited by missery

Share this post


Link to post
Share on other sites

@@missery

 

no, the admin folder name is not it, could it be you have no sression and are just relying on the htaccess login? what happens when you click on your admin logout link, do you stay logged in?

 

what version osC is it & what removed login?


Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Share this post


Link to post
Share on other sites

@@spooks

thanks for the reply, i do not have an admin logout link

i am running 2.2 rc2a

(you secured my admin after i was hacked a couple of years ago )

regards

Share this post


Link to post
Share on other sites

@@missery

 

Sorry, that was too long ago! :unsure:

 

Without checking back, this should work for you,

 

just before

 

$action = isset($_GET['action']) ? $_GET['action'] : '';

 

add

 

$no_session = (isset($_SERVER['PHP_AUTH_USER']) && !empty($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW']) && !empty($_SERVER['PHP_AUTH_PW']));

Edited by spooks

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Share this post


Link to post
Share on other sites

@@missery

 

Sorry, that was too long ago! :unsure:

 

Without checking back, this should work for you,

 

just before

 

  

$action = isset($_GET['action']) ? $_GET['action'] : '';

 

add

 

$no_session = (isset($_SERVER['PHP_AUTH_USER']) && !empty($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW']) && !empty($_SERVER['PHP_AUTH_PW']));

 

@@spooks

yes this seems to be working fine now, do i have a security risk if i am using the code above ?regards

Edited by missery

Share this post


Link to post
Share on other sites

@@missery

 

do i have a security risk if i am using the code above

 

No, that will not degrade your security in any way.


Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Share this post


Link to post
Share on other sites

I just want to let you know that I've tested on my other server and the results are almost identical to what I've reported earlier:

 

File Mode Zipping - no problems at all.

 

Memory Mode Zipping

7zip and WinRAR kept asking to confirm file replace and throwing errors.

 

Memory Mode GZipping

PHP Version: 5.3.10 Method: Tar Server OS: Linux

Fatal error: Allowed memory size of 41943040 bytes exhausted (tried to allocate 4720129 bytes) in /hosting/www/mystore/www/admin/includes/classes/tar.class.php on line 325

I've changed the error_reporting to 1 to see that error.


Absinthe Original Liquor Store

Share this post


Link to post
Share on other sites

@mr_absinthe

 

42Mb is low, is it a small site, that method requires at least double the site size for memory


Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Share this post


Link to post
Share on other sites

Hi Sam,

 

I updated the addon and I have the same problem as the other users with the replace issue when extracting. I looked at the ZIP file (created with with both methods) and I see that all folders also have a file with the same name with 0 bytes.

 

Regarding the GZIP file, when I try to open it with winzip I get the error "Error reading header after processing 305 entries.". I'm able to extract it though with WinRAR without any error, but when I look at the extracted folders I have 306 files while I should have more more than 2400 files.

 

I would also like to propose to change the date in the saved file to the format yyyy-mm-dd, so if you have several backups in the same folder they are sorted by year, then by month and then by day.

Edited by modem2.0

Share this post


Link to post
Share on other sites

Hi again Sam,

 

I reverted back to v1, and I believe I found another bug. I have the following exclude line in the php file:

$exclude = 'DIR_FS_BACKUP, DIR_FS_CACHE, SESSION_WRITE_DIRECTORY, images/products/, thumbs/cache/,  includes/modules/kiss_meta_tags/cache/' ;

and I have the following line in the page:

Excluded Folders: admin/backups/ + admin/tmp/ + tmp/ + images/products/ + thumbs/cache/ + includes/modules/kiss_meta_tags/cache/

When I download the ZIP file, I have the folder (catalog)/tmp with all the files inside, which are more than 4000 cache files.

From the order in the exclude string I believe the tmp/ folder is coming from the entry SESSION_WRITE_DIRECTORY, and I even replaced it by "tmp/" and "tmp", moved it to the beggining of the string, and I even deleted the entry DIR_FS_CACHE but I always download the tmp/ folder.

This is quite weird, as the other entries are excluded, only this one is kept.

Share this post


Link to post
Share on other sites

@@modem2.0

 

have a file with the same name with 0 bytes

 

yes, as stated before:

 

backup_website.php line 87, replace:

 

elseif (@IS_dir($file)) if ($zip->addEmptyDir($file) === false) $wok = false;

 

with:

 

elseif (@IS_dir($file)) if ($zip->addEmptyDir($name) === false) $wok = false;

 

 

Your just changing $file to $name in the code.

 

Regarding the GZIP file,

 

Thanks, the GZip tar passing is going to change drastically.

 

Date format: good idea, I'll incorporate that.

 

Exclude bug: Yes, odd, could you say if you have a catalog folder or are in the root. Could you also give the Server OS, thanks.


Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×