MySQL database backup and restore
1. Create Database Backup:
You can use mysqldump to create a simple backup of your database using the following syntax.
mysqldump -u [username] -p [password] [databasename] > [backupfile.sql]
- [username] – this is your database username
- [password] – this is the password for your database
- [databasename] – the name of your database
- [backupfile.sql] – the file to which the backup should be written.
You can also ask mysqldump to add a drop table command before every create command by using the option –add-drop-table. This option is useful if you would like to create a backup file which can rewrite an existing database without having to delete the older database manually first.
mysqldump --add-drop-table -u [username] -p [password] [databasename] > [backupfile.sql]
If you want to back up certain tables
mysqldump -u [username] -p [password] [databasename] [table1] [tableN]> [backupfile.sql]
If you want to back up multiple databases
mysqldump -u [username] -p [password] [databasename1] [databasenameN] > [backupfile.sql]
Or want to back up all databases
mysqldump -u [username] -p [password] --databases-all > [backupfile.sql]
2. Restore from database backup
Restore a particular database
mysql -u [username] -p [password] [database_to_restore] < [backupfile]
Restore all databases
mysql -u [username] -p [password] < [backupfile]
Create self signing SSL Certificate
- Generate server key
openssl genrsa -des3 -out server.key 4096 - Create certificate signing request
openssl req -new -key server.key -out server.csr - Sign the certificate signing request with the server key
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt - Make the server key that does not need the password
openssl rsa -in server.key -out server.key.insecure - Do some house cleaning
mv server.key server.key.secure
mv server.key.insecure server.key - Use the following files in apache configuration
server.key
server.crt
Force SSL on apache
mod rewrite should be enabled on apache. Add the following to your apache config file.
#########################################
#### XXX: BEGIN EDIT FOR MOD_REWRITE ####
#### This is intended to force HTTPS ####
#### for all inbound HTTP requests ####
####
# This module (mod_rewrite) simply tells Apache2 that all connections to
# port 80 need to go to port 443 – SSL – No exceptions
####
LoadModule rewrite_module modules/mod_rewrite.so
RewriteEngine on
####
# The line below sets the rewrite condition for mod_rewrite.so.
# That is, if the server port does not equal 443, then this condition is true
####
ReWriteCond %{SERVER_PORT} !^443$
####
# The line below is the rule, it states that if above condition is true,
# and the request can be any url, then redirect everything to https:// plus
# the original url that was requested.
####
RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L]
#### XXX: END EDIT FOR MOD_REWRITE ####
Linux Disable Hardware Beep Sound For Terminal
- If you are using xterm, open ~/.xsession file
$ cdAppend the following line:
$ vi .xession
xset b offSave and close the file.
- If you are using bash shell, open ~/.inputrc file
$ cdAppend following line:
$ vi .inputrc
set bell-style noneSave and close the file.
- If you want to turn off beep for VIM text editor, open vim config file ~/.vimrc
$ cdAppend following line
$ vi .vimrc
set vbSave and close the file.
Remove .svn folders
In order to clean up the SVN checkout, you can do
#deletes all .svn files/folders
find . -name ".svn" -exec rm -rf {} \;
OR
#deletes all .svn folders
find . -name ".svn" -type d -exec rm -rf {} \;
