Database Backups

Scott Truesdell

started: March, 2013

INCOMPLETE: this page is under construction

Periodic backup of the database is good practice.

Using the built-in ShopSite facility for backups is easy but it is not bullet-proof. Every backup over-writes the previous backup so it is possible to write bad data over good data and basically undo whatever safety the backup was supposed to provide. The only way to be truly safe is to do some manual backup procedures. Be very aware that you are manipulating important files; if you are not 100% certain about what you are doing, don't do it.

The database lives outside of the web path so you need to use ftp or shell commands to make manual backups. When ShopSite makes backups it sets very rigorous permissions on the backup file; it is basically untouchable except via the backup procedure built into the ShopSite backend.

The dabase lives at /home/forespar/ss-data/.

The live database is shopsite_db and the backup is shopsite_db.bak.

Since shopsite_db.bak is untouchable by us, we start by making a dated backup of the love database. The Unix command for this is:

cp shopsite_db shopsite_db_yyyy_mm_dd.bak

where yyyy is the current year, mm is the current month with leading zeros and dd is the current day with leading zeros. If you make multiple backups in a single day, append sequential numbers after _dd. Example: the 3rd backup on December 6, 2012 would be named:

shopsite_db_2012_12_06_03.bak

and the entire copy command would look like this:

cp shopsite_db shopsite_db_2012_12_06_03.bak

Since the backups are large, they need to be kept to a reasonable number. A good practice would be to keep one manual backup in addition to ShopSite's backup. After you make all your changes and have several backups and have determined that the database is in good shape, delete all but the most current of your dated manual backups and rename it without a sequence number.

screen-shot

directions

prev home next