Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

osCommerce Database Backups


wheely

Recommended Posts

I've set a oscommerce test site up and i'm making sure I can back it up.

 

Using the oscommerce built in backup tool, I stored a .sql backup removed a product and tried to restore the entire backup.

 

The product was still removed so the backup or restore didn't function correctly. Although no error was reported during the save or restore process. The contents of the .sql file looked fine.

 

Any ideas why?

 

As an alternative, I thought I would use phpMyAdmin to do a full backup of the database. Now this did save a file and restore it almost entirely correctly except. the images for the product catagorise were not display correctly!

 

Are all images stored in the database? Any idea's?

 

Wheely

Link to comment
Share on other sites

I have mine back up automatically via cron (both windows and Linux/Unix). If you have shell/console and access to cron (or another scheduler), this is definately the way to go. You can choose which tables to backup and what frequency to back them up (i.e. orders, orders_details, customers, address_book backup up every hour - the rest backup every day - of course this is just a suggestion - if you make lots of product changes, or have lots of newsletter activity - you would want to up the frequency on those).

 

This cron entry will do a full backup ot the entire database at 4:00am (machine time) every day.

 

0 4 * * * /usr/local/bin/ksh -c /tmp/script.sh

 

Here is the script: (call it script.sh - do a chmod +x script.sh and save it in the correct directory)

 

date=`date +"%m-%d-%Y-%H:%M:%S"`.sql

/usr/local/bin/mysqldump [database] -u [mysql userid] -p[mysql password] --complete-insert --add-drop-table > /tmp/backups/backup.$date

cd /tmp/backups

compress /tmp/backups/backup.$date

for i in `find ./ -name "backup*.sql.*" -mtime +4`

do

rm -f $i

done

 

It will:

 

1. create a filename with today's date

2. run mysqldump to populate the file with sql to rebuild the database from scratch

3. compress the file to save disk space

4. automatically clean the directory by deleting files more that 4 days old

 

Of course you can choose to put it somewhere else than the /tmp directory - like the .../catalof/admin/backups directory - then you will be able to see it in the admin toold section - and restore it from there as well (although I'm not sure if it will restore the compressed file - so if you are taking this route - you may want to skip the compress part of the script).

 

It works for me.

 

Mike

 

I've set a oscommerce test site up and i'm making sure I can back it up.

 

Using the oscommerce built in backup tool, I stored a .sql backup removed a product and tried to restore the entire backup.

 

The product was still removed so the backup or restore didn't function correctly. Although no error was reported during the save or restore process. The contents of the .sql file looked fine.

 

Any ideas why?

 

As an alternative, I thought I would use phpMyAdmin to do a full backup of the database. Now this did save a file and restore it almost entirely correctly except. the images for the product catagorise were not display correctly!

 

Are all images stored in the database? Any idea's?

 

Wheely

Link to comment
Share on other sites

Actually,

 

there is code in admin\includes\functions\general.php that deletes the image associated with a product when you delete the product. Images are not stored in the database, just the image name. So if you want to keep the images on the server, you need to comment out the section of the code that is deleting them.

 

look for function tep_remove_product($product_id) and change this:

 

if ($duplicate_image['total'] < 2) {

if (file_exists(DIR_FS_CATALOG_IMAGES . $product_image['products_image']))

{

@unlink(DIR_FS_CATALOG_IMAGES . $product_image['products_image']);

}

}

 

to this:

 

/* Removed code to delete image when deleting categories and/or products

if ($duplicate_image['total'] < 2) {

if (file_exists(DIR_FS_CATALOG_IMAGES . $product_image['products_image']))

{

@unlink(DIR_FS_CATALOG_IMAGES . $product_image['products_image']);

}

}

*/

 

Mike

 

I've set a oscommerce test site up and i'm making sure I can back it up.

 

Using the oscommerce built in backup tool, I stored a .sql backup removed a product and tried to restore the entire backup.

 

The product was still removed so the backup or restore didn't function correctly. Although no error was reported during the save or restore process. The contents of the .sql file looked fine.

 

Any ideas why?

 

As an alternative, I thought I would use phpMyAdmin to do a full backup of the database. Now this did save a file and restore it almost entirely correctly except. the images for the product catagorise were not display correctly!

 

Are all images stored in the database? Any idea's?

 

Wheely

Link to comment
Share on other sites

That explains it! Thanks mglas, and also many thanks for the backup script. I wanted to use cron ones the site is up and running - I expecting to get to try it out soon.

 

:thumbsup:

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...