topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday March 28, 2024, 6:30 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: SMF Forum Backup Scripts (perl and bash code to backup db and new uploads)  (Read 14849 times)

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
I'm uploading a pack of smf forum backup scripts i wrote.

There are no magical commands here -- just mostly an automating of standard database dump and tar/zip operation.

Even if you are not using the smf forum, the basic code could be useful to you if you are running a server and want a nightly backup of a database and/or newly uploaded files.



//---------------------------------------------------------------------------
Title: Backup scripts for SMF forum data
Date: 7/29/11
By: [email protected]
Discuss: https://www.donation...index.php?board=45.0
Download: https://www.donation...mf_backupscripts.zip
License: Open Source whatever
//---------------------------------------------------------------------------


//---------------------------------------------------------------------------
WHAT THIS IS:

A package of backup scripts (in bash shell script and perl languages), that
 are meant to be used to perform nighly backups of your smf database and
 attachment directory.

It will put your forum in maintenance mode while it runs the database
 backup.

Note: This has been tested with smf 1.x but should work on any version;
 it has been tested with INNODB tables; if you use another database engine
 it may be possible to modify the code to do backup without locking tables.
//---------------------------------------------------------------------------



//---------------------------------------------------------------------------
HOW TO USE:

First, you need to customize the files in the settings directory, to specify
 the directories where your smf forum and attachments are located, and where
 you want the created databases and attachment zips to be placed.

Then upload all files, and set them to be +x.  Create any destination directories
 you have specified.

Then have your daily cron run the runmybackups.sh file, or run it manually to test.
//---------------------------------------------------------------------------


//---------------------------------------------------------------------------
NOTES:

Database backups are named by Weekday (Mon,Tue,etc.) and will rotate and overwrite
 as the week recycles.  Except that on one day per week it will create a file
 named with the month, so that you will have one backup file per month up to a year old.

The attachment zipping is incremental.  Unlike the database backup, the script will
 always create a new file with new attachments since the last run.  It will never overwrite
 or remove old files.

You might use a file synchronizing ftp program to automatically download new backup files.
//---------------------------------------------------------------------------



//---------------------------------------------------------------------------
CREDITS:

I took the detailed instructions from code posted by user Vekseid on the smf
 forum: http://www.simplemac...x.php?topic=293441.0
And just tried to make a fuller configurable script out of it, plus added
 a helper script for backing up attachment files, which is important for us.
//---------------------------------------------------------------------------
« Last Edit: July 30, 2011, 07:49 AM by mouser »

Carol Haynes

  • Waffles for England (patent pending)
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 8,066
    • View Profile
    • Donate to Member
Is this SMF specific or will it work with any DB and collection of folders? Also can you include more than one DB?

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
It has some very specific code for smf stuff (like grabbing settings from the smf .php file and modifying this file to put it into maintenance mode), etc.

So for other uses you will have to modify quite a bit.

But it may still be useful as a skeleton for customization as it demonstrates how to do a few useful and tricky things.

Carol Haynes

  • Waffles for England (patent pending)
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 8,066
    • View Profile
    • Donate to Member
Thanks - I'll take a look

I was wondering if I could mod it to work with WordPress websites - there really aren't any good automatic backup options for them.