Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I have restored a mysql database, named pbcs7, from a backup that was created via a tar command, but the data is not there.
The database program - PBCS which is an appointment system - resides in /home/www/public_html and the mysql database is in /var/lib/mysql
It all started when I deleted one of the users, 'michael', that had admin rights, from one group and lo and behold 'michael' disappeared from all groups as did the data. My other admin user was still there, but the data belonged to 'michael'
Steps for restoration of the backup (permissions were found to be preserved):
1. the backed up 'pbcs7' database files were temporarily restored using the tar -zxvf command to:
2. made copy of files in use (ie the files from which data was missing) to...restore2 directory
cp -a /var/lib/mysql/pbcs7/* /var/lib/restore2/
3. /sbin/service mysqld stop
4. restored pbcs7 database files to the working mysql directory
cp -a /var/lib/restore/var/lib/mysql/pbcs7/* /var/lib/mysql/pbcs7/
Okay, was your backup an actual mysqldump backup or did you just simply copy the directory for the database from /var/lib/mysql?
From the looks, seems like you probably just backed up the files from /var/lib/mysql from a live database, which is going to give you unreliable backups.
In order to get good backups of unchanged data while a mysql database is running is to either use mysqldump and lock the tables during the dump or you need to shutdown the mysql database, then backup the files in /var/lib/mysql, then restart the database.
What do you restore files look like? You may need to drop the database from within mysql first, then copy over the files from a backup if they actually have data within them. If that doesn't work, you probably got a corrupt backup cause you didn't back them up properly.
There's no safe way to delete a database since you're dropping it from existence. Before you drop it, I'd suggest making sure your backed up copy is good and works, maybe testing on another system first.
And you might want to look into using mysqldump instead of doing cold backups of the files themselves.