Mysql, sqlsever, oracle, redis, mongo, postgres and other database backup and recovery commands, sqlseverredis
The following is a simple example of how to back up and restore each database. For more detailed parameters and configurations, refer to relevant information.
I. mysql:
Parameter description:
$ User |
$ Password |
$ Targethost |
$ Port |
$ Charset |
$ Dbname |
$ Table |
$ Filename |
User Name |
Password |
Ip (localhost) |
Port |
Encoding |
Database Name |
Table Name (only required for table-level backup) |
File Name |
Backup: mysqldump -- single-transaction-l-u $ user-p '$ password'-h $ targethost-P $ port -- default-character-set = $ charset $ dbname $ table> $ filename
Restore: mysql $ dbname-u $ user-p' $ password'-h $ targethost-p $ port -- default-character-set = $ charset <$ filename
Ii. sqlserver:
Note: sqlserver2003 and below only support osql, sqlserver2005 and above support both osql and sqlcmd. The following methods are applicable to sqlcmd and osql.
Parameter description:
$ User |
$ Passwrod |
$ Instance |
$ Dbname |
$ Filename |
$ Diff_filename |
User Name |
Password |
Instance name |
Database Name |
Full backup file name |
Incremental backup file name |
Full backup: osql-U $ user-P "$ password"-d master-S $ instance-Q "alter database $ dbname set offline with rollback immediate; restore database $ dbname from disk = '$ filename' with replace; alter database $ dbname set online"
Incremental Backup: osql-U $ user-P "$ password"-d master-S $ instance-Q "alter database $ dbname set offline with rollback immediate; restore database $ dbname from disk = '$ filename' with replace, NORECOVERY; restore database $ dbname from disk =' $ diff_filename 'with recovery; alter database $ dbname set online"
Full recovery: osql-U $ user-P "$ password"-d master-S $ instance-Q "alter database $ dbname set offline with rollback immediate; restore database $ dbname from disk = '$ filename' with replace; alter database $ dbname set online"
Incremental recovery: osql-U $ user-P "$ password"-d master-S $ instance-Q "alter database $ dbname set offline with rollback immediate; restore database $ dbname from disk = '$ filename' with replace, NORECOVERY; restore database $ dbname from dist =' $ diff_filename 'with recovery; alter database $ dbname set online"
Iii. oracle:
Oracle uses rman for backup and recovery. If you are interested, you can learn more about the specific use of rman.
Iv. redis:
Note: The redis data backup file is stored in the full path file name consisting of dir + dbfilename in the configuration file;
Backup: redis-cli-h targethost-p $ port-a $ password save
Recovery: you only need to store the backup file in the original directory and restart redis.
V. mongo:
Parameter description:
$ Targethost |
$ Port |
$ Dbname |
$ Backup_dir |
$ User |
$ Password |
$ Table |
$ Recovery_dir |
IP address |
Port |
Database Name |
Save path |
User Name |
Password |
Table Name (Table-level recovery) |
Recovery path |
Backup: mongodump -- host $ targethost: $ port-d $ dbname-o $ backup_dir-u $ user-p $ password
Recovery: mongorestore -- host $ targethost: $ port-d $ dbname-u $ user-p $ password-c $ table $ recovery_dir
Vi. ipvs:
$ Targethost |
$ Port |
$ User |
$ Dbname |
$ Filename |
$ Recovery_file |
IP address |
End Port |
User Name |
Database Name |
Backup File |
Restore Files |
Backup: pg_dump-c-B-h $ targethost-p $ port-U "$ user" $ dbname> $ filename
Restore: psql-h $ targethost-p $ port-U "$ user"-d $ dbname-f $ recovery_file
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.