How to Backup Database - Where is the SQL file located?



  • Hello All,

    I would like to know how ya’ll backup your FOG Database (SQL files)

    I am running my FOG setup on Ubuntu 10.04 and I understand the whole setup pretty well by now. This is after hosing the system a few times lol! What I am afraid of is losing all of the database entries, assets, images, settings, etc…

    I know there is a backup script that I can run that is included in the install folder, however I do not trust this and would much rather backup the specific files myself.

    DOES ANYONE KNOW WHERE THESE FILES ARE LOCATED?!

    And/or a good way of backing these up? Currently I am making a master image of my server with [B]Clonezilla[/B], and using [B]Back In Time [/B]to backup the entire root directory.

    Suggestions?

    Thanks,
    CASEY



  • This post is deleted!


  • [LEFT]You can restore a single database from a mysqldump of all-databases.[/LEFT]
    [LIST]
    [*]mysql -u root -p[I]PASSWORD[/I] --one-database [I]DB[/I] < [I]DBfilename[/I].sql
    [/LIST]
    [INDENT=1][LEFT][url]http://dev.mysql.com/doc/refman/5.1/en/mysql-command-options.html#option_mysql_one-database[/url][/LEFT][/INDENT]


  • Moderator

    i backup the images though not such a big thing for me as i only have 2 soon to be 3 images when i start testing/deploying window 7 x64.

    1. windows 7 all software deployed with SAD2 driver tool
    2. windows 7 all software deployed with SAD2 driver + games

    also my two master images are Virtual machines in virtualbox and get backed up from my box to a 2nd HD and to our servers along with fog mysql database, full inventory reports etc


  • Moderator

    I only dump and restore the fog database, not the entire mysql instance. Minor changes to the commands used, documented well in the mysqldump section of the mysql website.

    You can also tar+gzip your /opt/fog/, /var/www/fog/, and /tftpboot/ folders to preserve your fog installation. I host my images on a raid 5 array, so hopefully I do not lose them because of a disk failure. I have almost a 400GB of image files, so backing them up to another location takes a while.



  • You need to install FOG before you restore. The IP address should not matter when restoring a backup. You might have to go to the webpage and change the IP address under Other Info > FOG Settings. I have never changed IP’s when moving FOG so I am not sure if you need to do that.


  • Moderator

    when restoring after a ‘disaster’ do you build Ubuntu, Install FOG, then import the dump? does the server have to have the same IP etc



  • [FONT=Verdana][COLOR=#333333]mysql -u USERNAME -pPASSWORD < filename.sql[/COLOR][/FONT]

    [FONT=Verdana][COLOR=#333333]Where “filename.sql” is the backup file you created. Make sure to unzip the file before restoring the database if you used gzip from my earlier post.[/COLOR][/FONT]



  • That did it!!! Thanks!

    How do I restore it after say a fatal event occurs…

    Should I start a new thread?



  • I use “root” to backup all my databases. That or you will need to “GRANT” permissions to the FOG user. Also make sure your PASSWORD has no space after “-p”.



  • With this command (and similar ones) I always get the error message as follows:

    [I][B]mysqldump: Got error: 1045: Access denied for user ‘fog’@‘localhost’ (using password: YES) when trying to connect[/B][/I]



  • I usually keep my backups separate, especially with all my images. I take great care with those since I believe they are the most important. I copy my images as is to 2 different locations for backup purposes. You can get by with my post above with mysqldump. I do a backup of my Apache websites. You can use the command below.

    tar -czPf /***/Apache2/apache2_date '+%Y-%m-%d'.tar /var/www/



  • I use mysqldump to take a backup of all my MySQL databases. Run the command below, changing USERNAME and PASSWORD to your MySQL info. *** = a directory somewhere. It will save all your databases in a gzip file. Filename will look like this if done today “database_2012-03-09”.

    mysqldump -u USERNAME -pPASSWORD --all-databases | gzip > /***/MySQLBackups/database_date '+%Y-%m-%d'.sql.gz


Log in to reply
 

377
Online

39.3k
Users

11.0k
Topics

104.4k
Posts

Looks like your connection to FOG Project was lost, please wait while we try to reconnect.