PDA

View Full Version : Administrative and Maintenance Tools - Site Backup (easily backup your forum files)


bairy
09 Oct 2006, 16:53
What is this?
This is a script that will let you easily back up your website files, with some nifty features.

Why?
We all know backups are important, but they're also tricky. If you are on shared hosting with no shell access then you have to backup via FTP which is time consuming and a bit messy. Even if you have shell access you still have to manually type in the command to tar it all up, then download it, then delete the tar. This script does it all for you.


Okay, talk me through it
It's pretty simple really. Once you've uploaded and configured the script (read the install.txt), run it and you'll be presented with a list of folders and files in your forum root. You can choose the ones you want, click Backup! and it will put them into a tarball (which can be optionally gzipped). You can then download that tarball and delete it for security reasons, all from this script.
The advantage of being able to pick and choose the files you grab is that you don't have to keep downloading the files that never change. So say you have the images dir which never changes, and you have an uploads dir which does. It makes no sense wasting bandwidth continually grabbing the images dir.

Simply put: Your site is put into one file which is a lot easier to download than hundreds of seperate ones. It can be optionally gzipped to reduce the download size a bit more, and it's jus all round convenient.

Important
I cannot gaurentee this will work. It requires the tar executable to be in place and I believe that's only present in linux operating systems. It also requires you to be able to execute it. Safe mode may stop you doing so. Please don't ask me for support on this, I don't know the answers. I just know it works on my host so I thought I'd share.
Because I'm no expert I cannot be liable for any theft or problems occuring from this script. Run at your own risk!

Less important, but still important
When you do a backup, make sure you have enough space to actually fit the tar file. So if your admincp is 2mb, you'll need 2mb free on your hosting plan, or slightly less using gzip.


Questions
Is it secure?
Yes. As much as I know how to make it:
- You choose the backup filename. Even though it will be deleted as soon as you've downloaded it, this helps prevent anyone else from guessing the filename and downloading it at the same time
- It's restricted to superadministrators only, as defined in config.php.

What's to stop people browsing to the backup directory and seeing my backup?
There should be no backup except during download, however during download times there is a blank index file in the backup directory. If your web server is set up properly then it's extremely difficult to guess the filename you chose. Even I wouldn't be able to get hold of it without FTP details.

Why not just use cpanel's backup?
The only real advantage over cpanel's backup is you can choose the files you want, whereas cpanel dumps the entire public_html folder, and databases, and .... into it. I don't think cpanel provides a gzip option either.

Is a database backup included?
At this time, no. Maybe in the future if I can figure out how to do it.

Can this script wipe my files?
No. The only single thing it's capable of deleting is the backup file which you create and name.

The title says "forum files", what about CMS?
Truthfully I don't know because I don't have CMS. The way the admincp global works is it seems to put the forum root as the current working directory. I don't know if that means site root in the case of CMS, or just forum root. Best way to find out is run it and see which directories are listed.
If there is no CMS, I may look into including that or full website backup, if the demand is high enough.

Why doesn't it have anything in the vB options?
Security. Read the first few lines of the script itself for more details.

Can this be put on cronjob/scheduled task?
Nope. It's not designed as that at the moment although it wouldn't be too unsafe to do so. Maybe in the future when I know the commands and directory bits work properly.

What about sending the backup to another server, via ftp?
In future possibly, depends on demand.

Restoration option?
Not at present, depends on demand.

What is a tarball (.tar) anyway?
I'm not sure of the origins or if it's a *nix "standard" but it seems to be. Basically it's just a form of archiving files, sort of like zip or rar. You can also gzip the files on top, making a zipped tarball (.tgz) WinRar (http://www.win-rar.com/) will handle the file. If you want a free alternative try www.nonags.com (freeware - no nags)

Can you help me with...
As I said in the important part, this isn't an area of expertise to me. If you have a feature suggestion or have found a bug I'll do my best to fix it, but if it just plain doesn't work then I might be able to help, I might not.

AMG021
09 Oct 2006, 17:08
1st so say THANKS!!!

Quarterbore
09 Oct 2006, 17:23
This sounds great! I am installing now!

Edit - OK, I have it installed but it looks like this will not do a full site backup or at least mine does not look like it is working.

Edit - I am uninstalling this as she is not working for me... I'll watch the thread but this is to dangerous of a script to haev on a site if it is not going to work...

DPSR
09 Oct 2006, 17:37
WAH, bro it looks like you have just solved my biiiiggg problem but i have only one question:

My uploads folder size is about 2 gb :) will this script pack it also?? or there is certain limit to which this script work??

Thanks a lot once again :)

maxicep
09 Oct 2006, 17:49
thanx for hack

bairy
09 Oct 2006, 17:54
My uploads folder size is about 2 gb :) will this script pack it also?? or there is certain limit to which this script work??

You can exclude that directory, however if you include it the script will keep working until one of three things happen:
1. You run out of disk space and it stops.
2. It times out. php won't time out but the web server (apache, lighttpd) might. I believe apache is set to 300 seconds (5 mins) by default so I hope it's a fast disk in that server.
3. Some other problem such as the host rebooting the server.

Lionel
09 Oct 2006, 17:59
Can it be incremental?

DPSR
09 Oct 2006, 18:03
You can exclude that directory, however if you include it the script will keep working until one of three things happen:
1. You run out of disk space and it stops.
2. It times out. php won't time out but the web server (apache, lighttpd) might. I believe apache is set to 300 seconds (5 mins) by default so I hope it's a fast disk in that server.
3. Some other problem such as the host rebooting the server.

I have about 8gigs of free webspace left and i am on shared hosting account... will it work?? i just need to move this folder to another.. rest i can do ;)

bairy
09 Oct 2006, 18:06
Lionel - not as such. You can tick some directories one time then some more directories next time, but it'll overwrite the tar so you need to download it in between.

DPSR - Assuming you can have one single file that kind of size, yes. (Some hosts have a maximum size per single file - I'm not certain if there are filesystem limitations too). Best suggestion would be just try it.

DPSR
09 Oct 2006, 18:12
DPSR - Assuming you can have one single file that kind of size, yes. (Some hosts have a maximum size per single file - I'm not certain if there are filesystem limitations too). Best suggestion would be just try it.

Its a folder where i store attachments......... np i will this out :cool:

bairy
09 Oct 2006, 18:34
I understand what you mean.
What I mean is that a tarball is a single file containing everything put into it. So if you have 1000 attachments at 2mb each then it'll go into one big file of around the 2gb mark.
Some hosts don't allow any one file at that kind of size, and the linux filesystem may also have restrictions on it.

So in terms of the script, there's no reason it won't work, but there might be technical limitations that will stop it.

transitbus
09 Oct 2006, 18:41
Just installed it. Works perfectly. Thanks for making this.

kall
09 Oct 2006, 19:01
Nice.

A suggestion: You mention 'those directories that dont change' in the first post, but I can't see anything about 'last modified date' in the screenshots.

Perhaps something like that, to give people an idea of what needs backing up?

Maybe a 'has changed since last backup?' flag?

bairy
09 Oct 2006, 19:38
I did think about putting some info in the listings, like size. Last modified is a good idea too.
I wrote the whole thing in about 6 hours today and wanted to see if:
a) it would work on other servers
b) many people would be interested

Early impressions seem to indicate that it could be relatively popular, especially if I make it more functional.

da420
09 Oct 2006, 19:54
Very nice. I am very interested as it is kind of a mental thing in keeping back ups. The more current the back up the more at ease I am. I try and take a file structure back up at least once a week, but sometimes I cannot get around to it, and it gets done once a month, if that. This will help as all I will need to do is login to FTP and upload the single file.

This along with Paul M's auto database back up will be very helpful in the occurance something should happen so that we have the most up to date backup of the files, and getting the site back up in working order ASAP.

I will probably be installing this tonight.

Thanks!

projectego
09 Oct 2006, 20:49
Looks very helpful! I'll be sure to check this out... ;)

DPSR
10 Oct 2006, 08:34
Hey bairy, you made my day bro :D:D , it worked.. it made a backup .tar file of 1.5GB in about 30 minutes.

Although, it didn't gave any confirmation message from vbulletin control pannel.

But still it rocks!!!!

Quarterbore
10 Oct 2006, 15:14
I am some confused as this didn't work for me when I tried....

This should be compatable with 3.6.0 right? I will have to set up a developmental server and see if I can figure out if I have a conflict somewhere...

I would love to be able to customize this to so only backup my most critical directories (say classifieds or paid parts of the site) and do a nightly backup of these critical files via CRON or scheduled tasks...

bairy
10 Oct 2006, 16:10
Hey bairy, you made my day bro :D:D , it worked.. it made a backup .tar file of 1.5GB in about 30 minutes.

Although, it didn't gave any confirmation message from vbulletin control pannel.

But still it rocks!!!!
The web server software, usually apache, generally has a timeout (default 5 mins I believe). After that time it will just ...stop... transmitting. Basically that means you won't get the confirm message. I don't know if it'll carry on in the background on all servers, lucky that it did for you.


Quarterbone,
As I said in the intro, I don't know how to debug this because I don't fully understand how web servers have their servers set up. It works on 3.6 and "compatible" hosts. They are, so far as I can work out, those which let you run exec() and have the tar executable installed. Cron jobs (etc) are planned for future versions.

Quarterbore
10 Oct 2006, 17:01
OK, I have servers at three different hosts so I will set up some developmental forums on them and see if there is a possible php or mysql issue... I love the idea so I will work on resolving my issues...

rainyleaves
11 Oct 2006, 10:42
Very nice!!!
Thanks!!! bairy

tazB.ca
11 Oct 2006, 23:27
Warning: set_time_limit() [function.set-time-limit]: Cannot set time limit in safe mode in /admincp/sitebackup.php on line 125
Backup in progress... Please wait.

:confused:

Keyser Söze
12 Oct 2006, 01:12
i have linux rar on my server is it possible to have it auto rar the database?

also can i have it put the file in a place that is not accessable via the web, like root/site/right here the other folder would be public_html/forums/admincp/sitebackup

bairy
12 Oct 2006, 12:50
Warning: set_time_limit() [function.set-time-limit]: Cannot set time limit in safe mode in /admincp/sitebackup.php on line 125
Oh dear.
I can't do much about it (all you can do is ask your host to turn safe mode off) but I'll make note to suppress the error message, thanks.

i have linux rar on my server is it possible to have it auto rar the database?
I don't know how to access it. At some point I think I'm gonna install linux and apache etc., and test some of the different methods. For now though, it's not possible I can do it.

also can i have it put the file in a place that is not accessable via the web, like root/site/right here the other folder would be public_html/forums/admincp/sitebackup
Backup to where is planned for the next version (no idea when that'll be at this stage - got a lot going on).

Shazz
12 Oct 2006, 17:16
I have this successfully working I think. IF something was to go wrong in the forums, I backed it up currently... How would i restore it?

da420
12 Oct 2006, 18:40
Works great bairy! Thanks!

Doesn't backup CMPS, would be nice, but that's not a big deal.

vietkieu_cz
12 Oct 2006, 19:22
Does it work for vbb 3.5 version?

bairy
12 Oct 2006, 20:45
Shazz, I'll answer here rather than the pm so everyone can see.
There is no automatic restore function, basically you'd just put it all back via ftp.
I should think there is a relatively easy way to get the OS to untar all the files back, dunno if the tar format retains permissions though... one to research.

da420... damn, I didn't think it would to be honest, I need to do some more research and testing and see if I can incorportate that.

vietkieu_cz... I don't honestly know. I'm 95% the answer is yes because there's nothing particularly 3.6 specific in there that I know of, but you'd have to try it out.

Shazz
12 Oct 2006, 21:01
Shazz, I'll answer here rather than the pm so everyone can see.
There is no automatic restore function, basically you'd just put it all back via ftp.
I should think there is a relatively easy way to get the OS to untar all the files back, dunno if the tar format retains permissions though... one to research.

da420... damn, I didn't think it would to be honest, I need to do some more research and testing and see if I can incorportate that.

vietkieu_cz... I don't honestly know. I'm 95% the answer is yes because there's nothing particularly 3.6 specific in there that I know of, but you'd have to try it out.

I get that part... Replace all the files... But thats just the .php files and FTP

What about the actual Forums? Like if a thread was permently deleted and you wanted to restore last nights, so you would get that thread back.

bairy
12 Oct 2006, 21:17
That's in the database, which isn't covered by this hack.

Shazz
12 Oct 2006, 21:20
That's in the database, which isn't covered by this hack.
Wouldn't you use phpmyadmin SQL file it?

bairy
12 Oct 2006, 22:31
In general yes I use phpmyadmin.
Don't understand what you're asking here...

NiTRoN
05 Nov 2006, 20:53
nice tool.. can you add option to put current date at the end of the filename ur backing up into? Also.. can there be option to dump and chose which tables to get from sql database as part of backup?

Krumbz
07 Nov 2006, 01:50
I get

Backup in progress... Please wait.

Backup Complete. Click here to download it.


After the download has finished, click here to attempt to delete the file.


but it ends in like 2secs then when i click download now i get

Not Found

The requested URL /admincp/sitebackup/*********.tgz was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Apache/2.0.53 (Fedora) Server at forum.**********.com Port 80

Krumbz
07 Nov 2006, 18:58
uppin ???

bairy
08 Nov 2006, 23:01
NiTRoN: Date, I could but since the system is really designed to have backups done then moved off quickly, it's not top of the list. However it would provide a hard to guess (though easy to attack-crack) so it's not a bad idea... Database dump: Not planned to be honest. There is another hack that does it and I hear that has it's own issues.


Krumbz: Yes that's a "bug" I recently found. On a server I just switched to it think it's finished before it really has. Not really sure how to address that. If it really was "2 secs" then check the admincp/sitebackup folder is chmod'd to 0777.


All who are waiting for an update: Sorry, just got a new temp job and will be getting a new permanent job soon, lots of personal stuff so basically, an update could be a while if ever. If anyone wants to improve on it and release please do.

rknight111
11 Nov 2006, 16:05
Does this work with 3.6.3??

I am just working on changing hosts, I allready have my site on the other host. But I will tranfer the data on Wednesday once I put the site to sleep for the time it takes the DNS tranfer to take place. Then I could just install backed up info..

RON

bairy
12 Nov 2006, 10:30
Does this work with 3.6.3??
It should work on any version of vb down to 3.5, maybe even 3.0

If it doesn't work it's very easy to remove so you have nothing to lose by trying it

Krumbz
12 Nov 2006, 21:01
Bairy the folder is already CHMODED...same thing, can you please tell me how to make it work from here, I really am VERY interested in your mod.

bairy
13 Nov 2006, 16:42
If it doesn't write the file then I can't help because I don't know much about web servers/linux etc. (as I stated in the first post).
If it does write the file but just notifies you too early then again, I don't know why so I can't help.

unforsaken
17 Nov 2006, 05:14
When I install this and just access the site back thru the admincp I get the following error:

Warning: sort() expects parameter 1 to be array, null given in /admincp/sitebackup.php on line 70

Warning: sort() expects parameter 1 to be array, null given in /admincp/sitebackup.php on line 71

Warning: Invalid argument supplied for foreach() in /admincp/sitebackup.php on line 80

Warning: Invalid argument supplied for foreach() in /admincp/sitebackup.php on line 95


any thoughts on this issue. Its chmod, running on vb 3.6.3

bairy
17 Nov 2006, 08:46
That happens because the $dirs and $files arrays are empty, which basically means that it can't read the directory of files or dirs in /

Is sitebackup.php in admincp/
If so, is the chmod of the directory with showthread.php in it (i.e. the forum root) at least 0444? (IOW is the root directory readable)

wottech
17 Nov 2006, 22:37
Very nice... Just created a 1.8GB tar file. Much easier than the week I just spent trying to get it all manually via FTP!!

taheri6
25 Mar 2007, 21:29
any chance this can get modified to work with winrar for windows based systems?

Mrdby
22 May 2007, 00:48
good add on!!!

rjmjr69
22 May 2007, 01:23
WOW I love this thank you so very much. Couldnt get any easier to install and works without one issue on my heavily modified board running 3.6.7p1

713JunctionP
05 Jun 2007, 06:03
awesome.

will this save my edited templates and everything?

rjmjr69
05 Jun 2007, 18:45
Saves anything on the server. This is one of the best releases yet imo. Nominated Mod of the Month this works flawlessly

bairy
05 Jun 2007, 19:37
It won't save the templates because they're part of the database, this only does files.

Mr_Devlin
28 Nov 2007, 08:26
This addon doesn't work for me. I always get errors like this:

Warnung: exec() has been disabled for security reasons in /admincp/sitebackup.php (Zeile 178)

when I tried the gzip or

Warnung: exec() has been disabled for security reasons in /admincp/sitebackup.php (Zeile 171) when using tarball.

Have to uninstall this until errors can be fixed.

taheri6
28 Nov 2007, 17:21
its not errors in the plugin, that means your server operator has disabled the exec() function in php.

aapkae
23 Feb 2008, 18:42
bit dizzy here...

could you pls tell me easily way to back up 3.6.8 data base?
i want to move to new server without losing any existing files/attchmnt on my forum

mariocaz
23 Feb 2008, 21:24
I installed it, nice mod.

I am doing a back up, hope works fine.

Thank you!

Mario

Mrdby
01 May 2008, 22:55
3.7.0?

CrazyProgrammer
06 Jun 2009, 16:07
works for 3.8.0 testes