Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Contribution: Auto Backup Database


spooks

Recommended Posts

When I run the corn -> http://brs-giftshop....o_backup_db.php, I get this though:

 

 

 

The permission for auto_backup_db.php was set at 644, I assume that was done when installed. Do I need to change it to something like 755?

 

Bennett

 

 

more likely an issue with your htaccess, check there

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.

Link to comment
Share on other sites

more likely an issue with your htaccess, check there

 

Hi folks,

 

I have the same problem ;-) it is because a htacces password protection. Is there an ability to add password in path to dingsbum_backup.php ?

life long and knusper

Link to comment
Share on other sites

I'm sorry but I haven't fully understand the auto backup contribution. I have installed it and I have changed the "Auto Backup Interval" settings to every one minute. The "Backup Save Interval" is 24 hours. "Backup zip" is false.

 

So, when I am logging as admin, nothing is happening. I should have a backup in the server's folder /admin/backups but it's empty. I have set the folder options to "777" but still nothing. Only the osc embedded admin backup is working (manually). Is there also an option to have every day an automatic backup even we don't log in as admin?

 

Thank you.

Link to comment
Share on other sites

No backup on lgin

 

 

So, when I am logging as admin, nothing is happening. ).

 

 

 

how r u logging in to admin, with htaccess by any chance? please read the doc. wink.gif

 

 

Is there also an option to have every day an automatic backup even we don't log in as admin?

 

Thats what the cron option is for. smile.gif

 

 

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.

Link to comment
Share on other sites

  • 3 weeks later...

OK, there are many message points, seems I missed one when I added the cron option blush.gif

 

find:

 

 	$messageStack->add('', 'none');
$messageStack->add('Deleted expired backup from ' . $filename, 'warning'); 

 

replace with:

 

 	if ($cron) { echo 'Deleted expired backup from ' . $filename . " \n\n"; } else {$messageStack->add('', 'none');
$messageStack->add('Deleted expired backup from ' . $filename, 'warning');    	}

 

 

 

Hi Sam,

(I consolidated three areas of confusion so as to expedite any

solutions- hope you don't mind this shopping list)

 

Firstly, Thanks very much for the auto db backup contribution-

it works flawlessly and provides welcome peace of mind- the only

snafu is that the old backups are accumulating and I haven't

managed to pinpoint where I messed up-

 

1. Does anything suggest itself as to how to remedy accumulating db backups?

 

2. Should auto_backup_setup.php be deleted after running it (some contributions

mention removing similar types of sql install files and I've learned not to assume too often)

 

Question regarding Database_backup_manager, is the screen supposed to go blank after making a backup?

specifically after hitting the backup button in Database Backup Manager and waiting a few seconds the url adds NOW to the end of the querystring;

 

https://mysite.com/admin folder/backup.php?action=backupfilesnow

 

and the screen goes blank, in the bottom left corner is the word: Done

 

3. Should there be something displayed in the blank area?

(I just hit the back button to return to the Database Backup Manager)

 

Before asking that question I tried your link from the install text of Database_backup_manager_v1.4 but it appears to be a DEAD LINK?

 

"At the moment (June 2008) there appears to be a problem in certain situations where the list of checkboxes

with all the tables you want to backup is not completely transfered by the post protocol

(see Sam/spooks post: http://www.oscommerce.com/forums/index.php?s=&showtopic=293949&view=findpost&p=1256514 ).

I haven't been able to replicate that error on my computer so don't know if it is an issue with either the PHP version, server, or browser."

- from Database_backup_manager_v1.4 INSTALL TEXT

 

Lastly regarding the code update quoted at the top of the post:

find:

 

 	$messageStack->add('', 'none');
$messageStack->add('Deleted expired backup from ' . $filename, 'warning'); 

 

replace with:

 

 	if ($cron) { echo 'Deleted expired backup from ' . $filename . " \n\n"; } else {$messageStack->add('', 'none');
$messageStack->add('Deleted expired backup from ' . $filename, 'warning');    	}

 

3. Where is this code located? (I looked in includes/auto_backup_db.php but the closest I could find was:

 

$messageStack->add_session('', 'none');

$messageStack->add_session('Deleted expired backup from ' . $filename, 'warning');

 

($messageStack->add_session NOT $messageStack->add)

 

Thanks for your patience and expertise regarding any of the above,

 

jk

Link to comment
Share on other sites

 

 

2. Should auto_backup_setup.php be deleted after running it (some contributions

mention removing similar types of sql install files and I've learned not to assume too often)

 

 

 

Its says in instructions!!

 

3 etc Database_backup_manager has its own support thread

 

1. delete with ftp

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.

Link to comment
Share on other sites

Hi Sam,

 

Thanks for your swift reply.

 

Just to recap:

1. Use ftp to delete auto db backups. affirmative

2. It says in instructions! little fuzzy on this...

Here are the last two instructions (5 + 6) on my copy of (Auto Backup Install V2.8)

5. In /admin/includes/languages/english.php

before the last ?> add:

define('ERROR_BACKUP_DIRECTORY_DOES_NOT_EXIST','Error, Backup Directory Does Not Exist,

please create it or run "auto_backup_setup.php"');

 

6. ensure you have already logged into your site, then goto the setup page by pasting

into the url something like www.mysite.com/catalog/admin/auto_backup_setup.php

it will add the settings to the database & create the backup directory if needed.

its normally at catalog/admin/backups.

 

The defined variable in auto_backup_db.php are standard, so nothing further needed.

- end of instructions

 

I mention this in case my copy of the instructions is

somehow different and missing the part about deleting

auto_backup_setup.php after executing the sql insert-

I had theorized that maybe it was needed in the course

of doing the periodic automatic backups- glad to have

clarified that it should be deleted once configured.

 

3. "sorry wrong number"

 

that only leaves the last bit regarding a code update and if I did somehow

not get the complete instructions on deleting the auto_backup_setup.php

maybe other parts are missing as well like the segment below

 

$messageStack->add('', 'none');

$messageStack->add('Deleted expired backup from ' . $filename, 'warning');

 

replace with:

 

if ($cron) { echo 'Deleted expired backup from ' . $filename . " \n\n"; } else {$messageStack->add('', 'none');

$messageStack->add('Deleted expired backup from ' . $filename, 'warning'); }

 

(I looked in includes/auto_backup_db.php but the closest I could find was:

 

$messageStack->add_session('', 'none');

$messageStack->add_session('Deleted expired backup from ' . $filename, 'warning');

 

NOTE: $messageStack->add_session (NOT $messageStack->add like your code)

 

In which file is: $messageStack->add('', 'none');

$messageStack->add('Deleted expired backup from ' . $filename, 'warning');

located?

Or should the code be modified replacing the instances of $messageStack->add

with $messageStack->add_session?

 

Thanks for your understanding and assistance,

jk

Link to comment
Share on other sites

  • 1 month later...

Sam, would you please help me with changing the code from eregi_replace to preg_match?

 

I've managed to change it almost in the whole file, for example

 

old

$at_entry = eregi_replace('[.a-z]', '', $at_entry);

 

new

$at_entry = preg_match('/[.a-z]/i', '', $at_entry);

 

However I'm struggling with these lines

$at_entry = eregi_replace(DB_DATABASE . '[_-]', '', $at_entry);

 

changing it to

$at_entry = preg_match(DB_DATABASE . '/[_-]/i', '', $at_entry);

does not seem to work, still receiving Warning: preg_match(): Delimiter must not be alphanumeric or backslash in /hosting/www/store/www/admin/includes/auto_backup_db.php on line 103

Absinthe Original Liquor Store

Link to comment
Share on other sites

Sam, would you please help me with changing the code from eregi_replace to preg_match?

 

I've managed to change it almost in the whole file, for example

 

old

$at_entry = eregi_replace('[.a-z]', '', $at_entry);

 

new

$at_entry = preg_match('/[.a-z]/i', '', $at_entry);

 

However I'm struggling with these lines

$at_entry = eregi_replace(DB_DATABASE . '[_-]', '', $at_entry);

 

changing it to

$at_entry = preg_match(DB_DATABASE . '/[_-]/i', '', $at_entry);

does not seem to work, still receiving Warning: preg_match(): Delimiter must not be alphanumeric or backslash in /hosting/www/store/www/admin/includes/auto_backup_db.php on line 103

 

you have errors with both!!

 

$at_entry = eregi_replace('[.a-z]', '', $at_entry);

would be replaced with:

 

$at_entry = preg_replace('/[.a-z]/i', '', $at_entry);

 

and

 

$at_entry = eregi_replace(DB_DATABASE . '[_-]', '', $at_entry);

 

would be replaced with:

 

$at_entry = preg_replace('/' . DB_DATABASE . '[_-]/i', '', $at_entry);

smile.gif

 

 

PS perhaps u can answer a query of mine, ith genuine absinthe, should it be clear after adding water? huh.gif

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.

Link to comment
Share on other sites

you have errors with both!!

 

$at_entry = eregi_replace('[.a-z]', '', $at_entry);

would be replaced with:

 

$at_entry = preg_replace('/[.a-z]/i', '', $at_entry);

 

and

 

$at_entry = eregi_replace(DB_DATABASE . '[_-]', '', $at_entry);

 

would be replaced with:

 

$at_entry = preg_replace('/' . DB_DATABASE . '[_-]/i', '', $at_entry);

smile.gif

 

 

PS perhaps u can answer a query of mine, ith genuine absinthe, should it be clear after adding water? huh.gif

Certainly not a good idea to try some coding with fever ;-) and I wish my learning curve was steeper. I hope that I've got it right this time - it appears to be working fine. New code on lines 103 - 109 (approximately):

	 	$at_entry = preg_replace('/' . DB_DATABASE . '[_-]/i', '', $at_entry);
   	        $at_entry = preg_replace('/[.a-z]/i', '', $at_entry);

	$at_last = strstr($at_last, DB_DATABASE);

	$at_last = preg_replace('/' . DB_DATABASE . '[_-]/i', '', $at_last);
	$at_last = preg_replace('/[.a-z]/i', '', $at_last);

 

next is line 183 (I've kept the commented line to make it easier to follow)

//			$at_schema = ereg_replace(",\n$", '', $at_schema);
		$at_schema = preg_replace("/,\n$/", '', $at_schema);

 

lines 218 - 226

//						$at_row = ereg_replace("\n#", "\n".'\#', $at_row);
					$at_row = preg_replace("/\n#/", "\n".'\#', $at_row);	
					$at_schema .= '\'' . $at_row . '\', ';
				} else {
					$at_schema .= '\'\', ';
				}
			}
//				$at_schema = ereg_replace(', $', '', $at_schema) . ');' . "\n";
			$at_schema = preg_replace('/, $/', '', $at_schema) . ');' . "\n";

Edited by Jan Zonjee
thanks for not using the osC forums to spam your shop

Absinthe Original Liquor Store

Link to comment
Share on other sites

Since my reply was edited / deleted, I can send you PM if you like. dry.gif

 

 

Hi, its OK I did read it b4, seems Jan is beiing a bit sevear there, perhaps he did'nt spot it was a reply!! You had'nt put any links either!!! ohmy.gif

 

 

Thanks for the info though. smile.gif

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.

Link to comment
Share on other sites

  • 4 weeks later...

If we have autobackups on a cron job, does the cron job overide the admin settings or do they work together? I have cron job to create a db backup every 6 hours..but I have the admin setting as default..(autobackup interval 20 mins, autosave interval 24hrs)

 

Should I synch them or does it not matter?

 

Also I re-read the instructions and it doesn't clearly say whether or not to delete auto_backup_setup.php so can you clarify if we should delete this?

Contributions installed: Purchase without Account / STS/ All Products/ Header Tags Controller

Link to comment
Share on other sites

 

Should I synch them or does it not matter?

 

 

 

No , it does not matter, its automatic, if the cron job happens just after a backup & within your set time limits, it will skip the job.

Also I re-read the instructions and it doesn't clearly say whether or not to delete auto_backup_setup.php so can you clarify if we should delete this?

Yes, delete auto_backup_setup.php

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.

Link to comment
Share on other sites

  • 1 month later...

Is there any conflicts with this if I rename admin?

 

 

no

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.

Link to comment
Share on other sites

  • 1 month later...

I tried setting up this on a cron job and it doesn't work. I got an email notification with this:

/bin/sh: line 1: /root/public_html/admin/backups/backup.log: Permission denied

 

Any clue what I did wrong?

 

My store is hosted in the root domain btw.

Edited by sarafina

Contributions installed: Purchase without Account / STS/ All Products/ Header Tags Controller

Link to comment
Share on other sites

I tried setting up this on a cron job and it doesn't work. I got an email notification with this:

/bin/sh: line 1: /root/public_html/admin/backups/backup.log: Permission denied

 

Any clue what I did wrong?

 

My store is hosted in the root domain btw.

 

 

Cron job setups vary by server, if you have any issues there speak to your hosts, I`ve tested on a variety of servers & barring variations required by each, I`ve seen no issues.

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.

Link to comment
Share on other sites

  • 1 month later...
  • 2 months later...

Spooks,

 

I'm just not understanding the configuration settings. My goal is to have the modification automatically make a backup at a specific time every day. I set the cron job up to do that. I would prefer the modification not to backup any other time then when the cron executes. Would you be so kind and tell me the settings I should have set. Also I want it keep the last 31 days of backups.

 

I appreciate your help.

 

Ryan

Link to comment
Share on other sites

  • 3 months later...

I would just like to say here that I have implimented this contribution with great success (once I got my head round how it works)so very well done to the author of this great contribution!

 

One thing I did notice was that as auto_backup_db.php doesn't include the applicaiton_top.php. I found that the date and time being used to generate the file name wasnt the same as when the database manager was saying the back up was made. Having made a small modification to auto_backup_db.php solved that problem.

 

The way I use it is as follows;

 

I have a windows sbs 2003 server which has all the day to day office functions on it including exhcange, general file sharing and accounting systems data etc. On this server I am making use of the job scheduler, so I wanted to keep all my backups and other processes in one place (mostly for ease of admin) so I found a way of being able to call and run a remote php from the server, after much research I found the best way was to use a little command line ftp utility called Wget.

 

What I then did was to set the 2 parameters in the auto backup admin to time interval of 30 minutes and archive interval of 1 1/2 hours. I then scheduled a job in the sheduler on the local server to run auto_backup_db.php every 2 hours, this process starts at 02:00 every morning and does the last one at 22:00. This generates 11 backups at 2 hour intervals over a 22 hour period.

 

My main backup batch script runs at 23:45 every night, (only to keep the dates correct for the day) this calls auto_backup_db.php agian to make the 12th backup .sql file, then it generates new folders by date in the external data backups folder on the raid 5 array and using Wget again downloads the .sql files for the day to a database backup folder and then the entire content of the site to a system folder (excluding the .sql files).

 

This process also backs up 2 other static websites in the same way, then providing the .sql files were downloaded successfully, deletes them from the remote server. Unfortunately Wget doesn't support delete remote files, so I had to resort to building a conventional command line ftp script from within the main backup batch script that does an mdelete of the .sql files by date for that days files only.

 

Once this process is complete, it then does a backup to tape of all data on the raid array using good old NTBackup. The good thing is this is a totally automomous process, the only user intervention requird is to remember to put a tape in the drive!

 

I think this is about as complete a backup process as one could hope for, it certainly gives me confidence in knowing I could if necessary recover from just about any situation including a full rebuild with a copy of the database which is no more than 2 hours old at most. Of course these timings could be changed to suit any purpose, but 2 hours is fine for my needs.

Link to comment
Share on other sites

  • 3 weeks later...

Ok I have a strange thing happening. Its not a error but once I installed this cool contribution, I started browsing around to make sure it didn't break anything with the admin side of the site.

 

I found that before I added this. The "module" part of the admin site would come up and state "Payment module". But after install this one it now reads "Database Backup Manager".

 

This is my first addon for this fresh clean install.

 

I am running

osCommerce Online Merchant v2.2 RC2a

 

Server OS: Linux 2.6.18-164.15.1.el5PAE

Database: MySQL 5.0.91-log

PHP PHP Version 5.2.14

 

Any thought on why this happened. Other than this little mix up the addon works wonderfully.

Link to comment
Share on other sites

  • 3 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...