Backup(dump) and Restoring a mysql DB May 21, 2008
- Dumping all databases of a hosts
$ mysqldump -u root -psecret --all-databases > DATABASE.sql
other options can be used with this
--skip-opt --force --no-data --no-create-info (see man page of mysqldump for detail)
- Dumping a particular database
$ mysqldump -u root --databases design > design.sql
- Restoring backup of all databases
$ mysql -u root -psecret < DATABASE.sql
- Restoring backup of a particular database
$ mysql -u root -psecret -D design < design.sql Simple backup scripts
- mysqldump -A –password=xxxxxx | gzip >/mysql_backup/`date +%m%d%y_%T`.sql.gz
Magic command of tar May 21, 2008
If we want to send a large file to a remote host, we first compress (using tar cvzf’) the file then send (using scp) that file to the remote host and then uncompress (using tar xzvf) the file to view. so this is lengthy and time consuming.
If we use the following single line command it will reduce time to a significant amount ( take only 1/3 time of the above procedure).
tar czvf - <File-U-Want-to-tar> | ssh tarique@192.168.6.5 "cat | tar xvzf -"
OR
tar czvf - <file-u-want-to-tar> | (ssh tarique@192.168.6.5 tar xvzf -)
Efficient use of scp command May 21, 2008
Sometimes you need to copy a file from a remote hosts.In this case we can use the scp command in a different fashion,not only different but a efficient way to copy the file from the remote hosts not logging into that remote host.
The syntax is as follows-
$ scp <remote-host-name/IP>:<remote-host-file-name-with-location> <path-you-want-to-keep-file>






