Saturday, August 30, 2008
STEP 1: Restore table structure
If the table structure is corrupted, you need to retrieve the CREATE TABLE statements from the backup. To do this you can use grep:
zcat backup.sql.gz | grep -A 20 'CREATE TABLE `tablename1`' > tablestructure.sql
This command will create tablestructure.sql containing the CREATE TABLE statement and 20 lines after that. You may have to change the parameter from 20 to whatever to get the entire statement.
Once tablestructure.sql had been edited to only contain the proper CREATE TABLE statement, you may now restore the table structure.
mysql -u user -p dbname < tablestructure.sql
STEP 2: Extract and restore the table data
This command will create a sql file for the table.
zcat backup.sql.gz | grep 'INSERT INTO `tablename1`' > tabledata.sql
If the resulting sql file is small enough, you may load the table straight back into the database.
mysql -u user -p dbname < tabledata.sql
OPTIONAL: If you have a huge table and want to partially restore or batch things, you may want to split the table data into multiple lines.
split -l 100 tabledata.sql
This will create multiple files of 100 lines each named xaa, xab, xac, etc. You may then load each file separately.
If some rows are already on the table and you just don't want the INSERT to fail on a duplicate primary key, you can use sed to add the IGNORE option to the INSERT statement. The command below simply does a search and replace on the source file and writes it to a new file.
sed 's/INSERT/INSERT IGNORE/' < tabledata.sql > newtabledata.sql
That should do the trick.
Wednesday, August 13, 2008
This guide has been updated for Ubuntu Hardy 8.04.1. The following is the official installation guide:
The preseed method will enable a more automated install. You will want to enter the proxy a local apt-cacher server if you have one to speed up the updates and installs of new packages.
Post Installation Tasks
Updating and Installing Packages
In Synaptic, configure proxy as needed. If you have an apt-cacher service running on the proxy server, it will make your updates much faster if the packages have already been downloaded by a prior machine.
Click on Reload
Click on Upgrade
Configure Desktop to Remove Annoying Stuff
In System -> Administration -> Login Window -> Accessibility, uncheck the sounds
In System -> Preferences -> Sounds -> Sounds, uncheck Play System Sound to remove annoying sounds
If you want to change the desktop wallpaper for everyone:
In the desktop, type Alt-F2
Enter your password if prompted
Choose /desktop/gnome/background from the tree on the left
Change the picture_filename key to (e.g.) usr/share/backgrounds/ubuntu-calendar.png
Right click and Set As Mandatory or Set As Default. Mandatory means users cannot change the wallpaper.
You will also want to change the default fonts to the liberation fonts. It makes the menus and fonts in your applications more compact.
The scripts below will set the default fonts and settings without going through the GUI. Just change the mandatory to defaults if you want to allow users to change it.
sudo gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --set /apps/nautilus/preferences/desktop_font --type string "Liberation Sans 9"
sudo gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory--set /desktop/gnome/interface/document_font_name --type string "Liberation Sans 9"
sudo gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory--set /desktop/gnome/interface/font_name --type string "Liberation Sans 9"
sudo gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory--set /desktop/gnome/interface/monospace_font_name --type string "Monospace 9"
sudo gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.defaults --set /desktop/gnome/sound/event_sounds --type bool "false"
Adding a New User
System -> Administration -> Users and Groups, Unlock (You will asked for your password.)
Add User as Desktop User Profile. This user will not be able to install new packages.
Adding a Printer
System -> Administration -> Printing
New Printer -> HP JetDirect
Enter the IP of the network printer
Change Printer Options to a default media size of Letter instead of A4 if you are in the Philippines.