Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.7 > vBulletin 3.7 Add-ons
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Cron job for Files Backup (attachments, avatars, etc.) Details »»
Cron job for Files Backup (attachments, avatars, etc.)
Version: 1.0.2, by Lynne Lynne is offline
Developer Last Online: Oct 2022 Show Printable Version Email this Page

Category: Administrative and Maintenance Tools - Version: 3.7.x Rating:
Released: 03-09-2008 Last Update: 02-19-2009 Installs: 26
Re-useable Code Additional Files Translations  
No support by the author.

This is a script meant to run as a Scheduled Task to backup your files if you have your attachments, avatars, etc. in the file system. I have been running it for a couple of years now and given it to a few other vb admins and figured I should share it here as my first Mod. I found the basic part of the script somewhere online a couple of years ago and modified it to work with vbulletin.

Installation:
Download the file and modify the variables at the top of the file. The $backupdir should be an absolute path to a folder you wish to backup. Make sure you have a trailing "/" in the path. The $backupto variable is the absolute path to the folder for your backups. It should also have a trailing "/" in the path. Once you fill in those variables, upload the file to your "includes/cron/" directory and go to your Admin CP > Scheduled Tasks > Add New Scheduled Task and create a new task to run the script. I run mine every night (as seen in the attachment).

Notes:
The script I have attached is made to backup three different directories. You may add more or take away some. But, make sure if you add more at the top ($backupdir4, $fileprefix4) that you add them to the backupsus call. I used to have these variables set as globals in the function, however that stopped working for me after my last upgrade and instead of figuring out if this was a server issue, I simply changed the script to accommodate the change.

I have heard that some servers do not allow the use of the passthru() function. I can't help with that as I really don't know anything about servers and their personalities. Also, I assume this will work with windows servers also, but I can't help with that either as I have absolutely no experience with windows servers. This works for me and I hope it works for you to. I'm big on having backups around as it helps me sleep better at night.

And, thanks to Boofo for encouraging me to release my first modification!

Update:
1.0.1 - I forgot a semi-colon at the end of the $backupdir lines
1.0.2 - was: $backupattach = "cd $backupdir2;
s/b : $backupattach = "cd $backupdir3;

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #12  
Old 04-22-2008, 08:12 PM
Jase2 Jase2 is offline
 
Join Date: Dec 2007
Location: USA
Posts: 1,575
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Still getting the same error. Hmmm......
Reply With Quote
  #13  
Old 04-22-2008, 09:21 PM
Jase2 Jase2 is offline
 
Join Date: Dec 2007
Location: USA
Posts: 1,575
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Here's my attached file, Lynne -- as my email client is acting up lol.
Reply With Quote
  #14  
Old 04-22-2008, 09:28 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

For some reason, the lines are getting all run together by your editor and that is why you are getting the error.

For instance, your file line 1 shows:
Code:
 <?php/*======================================================================*\
Whereas it should only be:
Code:
 <?php
I will email a fresh copy of the script to you. This is very strange! You are the first person to say this has happened to the file.
Reply With Quote
  #15  
Old 04-22-2008, 09:37 PM
Jase2 Jase2 is offline
 
Join Date: Dec 2007
Location: USA
Posts: 1,575
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I believe that is from:
Code:
/*======================================================================*\
|| #################################################################### ||
|| # Cron Job to backup all avatars, profiles, and attachments			||
|| # Last Modified: December 04, 2007                                   ||
|| #################################################################### ||
\*======================================================================*
I'm using CofeeCup HTML editor 2008, paid version.

Just ran it again, and it worked. However, files are not showing up. I've cmod the backups folder, still isn't working. This is really strange.
Reply With Quote
  #16  
Old 04-22-2008, 09:42 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Jase2 View Post
I believe that is from:
Code:
/*======================================================================*\
|| #################################################################### ||
|| # Cron Job to backup all avatars, profiles, and attachments            ||
|| # Last Modified: December 04, 2007                                   ||
|| #################################################################### ||
\*======================================================================*
I'm using CofeeCup HTML editor 2008, paid version.

Just ran it again, and it worked. However, files are not showing up. I've cmod the backups folder, still isn't working. This is really strange.
I know what the code is from, however it is on line two of my script and if you look at what you attached, line 2 of my script is merged in which line 1 in your attached script. And, that happened with several lines. Very weird, as I said. I'm not sure why that would happen. I am just using a simple text editor, BBEdit, to write it and I don't think it should cause that problem. Who knows.

Is the action getting logged, just not producing any output? Are you getting any files output? Did you run it 'as-is' or with your modifications? Do you know if passthru() is an allowable function on your server?
Reply With Quote
  #17  
Old 04-22-2008, 09:49 PM
Jase2 Jase2 is offline
 
Join Date: Dec 2007
Location: USA
Posts: 1,575
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lynne
Do you know if passthru() is an allowable function on your server?
That I'll have to find out. I'll report back tomorrow. I'm too tired, need some sleep now. See you tomorrow! Thanks for your help, too.
Reply With Quote
  #18  
Old 04-23-2008, 02:12 PM
Jase2 Jase2 is offline
 
Join Date: Dec 2007
Location: USA
Posts: 1,575
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hello Lynne,

Haven't seen if passthru() is enabled on my server, yet (although I think it is) -- but I just noticed the attach, avatars, and profilepics in my forums directory as a .tar file. Any ideas as to why it is saving too my forums directory? I certainly don't have that set for the backup folder.
Reply With Quote
  #19  
Old 04-23-2008, 03:53 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Jase2 View Post
Hello Lynne,

Haven't seen if passthru() is enabled on my server, yet (although I think it is) -- but I just noticed the attach, avatars, and profilepics in my forums directory as a .tar file. Any ideas as to why it is saving too my forums directory? I certainly don't have that set for the backup folder.
If you are getting some files, then passthru is working fine.

It sounds like either you don't have the correct path set for the backup directory you want them to be moved to, or you don't have the correct permissions set for the directory. The script makes the backup and then moves the file. Looking at the file you attached above, you have this as your line:
$backupto = "/home/user/backups1";

You need to add the trailing slash. It should be:
$backupto = "/home/user/backups1/";
Reply With Quote
  #20  
Old 04-23-2008, 05:27 PM
Jase2 Jase2 is offline
 
Join Date: Dec 2007
Location: USA
Posts: 1,575
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi Lynne,

That is an old file, the new one has the trailing slash. I have also cmod the folder to 777. Any other suggestions..... ?
Reply With Quote
  #21  
Old 04-23-2008, 05:34 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Jase2 View Post
Hi Lynne,

That is an old file, the new one has the trailing slash. I have also cmod the folder to 777. Any other suggestions..... ?
I'd have to look at the form to see if something else is wrong. You can try attaching it here or sending it via email (if you have that working again). It seems that if the permissions and ownership is correct, it should work.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:43 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.06240 seconds
  • Memory Usage 2,308KB
  • Queries Executed 25 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (4)bbcode_code
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete