vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   [How To] Automated bash cron backup. (https://vborg.vbsupport.ru/showthread.php?t=105225)

Club3G 01-13-2006 02:44 PM

[How To] Automated bash cron backup.
 
Originally a question, figured it out, thought I'd share.

To automatically make a backup of your database using cron:

Code:

#! /bin/bash
# Automated database datestamp backup

mysqldump --opt -Q -u dbusername -pPassword dbname > /path/to/backups/`date --iso-8601`.sql

Open it up, replace:
  • dbusername
  • Password
  • dbname

With the proper information. Note that there is no space between -pPassword, it's intentional.

Then replace "/path/to/backups/" with the actual path that you want to put them in. Make sure the directory exists.

Put the backup.sh file in the appropriate cron folder. I'm running mine weekly, so mine is in /etc/cron.weekly/. CHMOD it +x (chmod +x backup.sh)

Output of it is a database file, named (the date).sql.

Putting it in cron.weekly will run it every Sunday night at Midnight, and give you a file that looks like this:

Code:

[cron.weekly]# sh backup.sh
[cron.weekly]# ls /home/backups/
2006-01-13.sql
[cron.weekly]#


Club3G 01-15-2006 05:33 AM

Just want to throw this one and only bump.

If you're a geek such as myself and have FTP access out from work (and a decent connection) you can setup a cron job there to download 'em automatically as well.

Peace of mind. :)


All times are GMT. The time now is 09:27 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.00962 seconds
  • Memory Usage 1,708KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (2)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete