[dbadmin@localhost ~]$ /opt/vertica/bin/vbr.py --setupconfig Snapshot name (backup_snapshot): full_backup20160505 Number of restore points (1): 1 Specify objects (no default): Object restore mode (coexist, createOrReplace or create) (createOrReplace): Vertica user name (dbadmin): dbadmin Save password to avoid runtime prompt? (n) [y/n]: y Database user password to save in vbr password config file (no default): Node v_windy1990_node0001 Backup host name (no default): 192.168.231.110 Backup directory (no default): /home/dbadmin/backup Change advanced settings? (n) [y/n]: y Temp directory (/tmp/vbr): Number of times to retry (2): Seconds between retry attempts (1): Encrypt data during transmission? (n) [y/n]: Use checksum for data integrity (not file data and size)? (n) [y/n]: Port number for rsync daemon (50000): User name to access rsync daemon (no default): Password of the user who accesses rsync daemon: Backup transfer bandwidth limit in KBps or 0 for unlimited (0): Number of concurrency for backup (1): Restore transfer bandwidth limit in KBps or 0 for unlimited (0): Number of concurrency for restore (1): Password file name (no default): password Saved vbr password to password. Config file name (full_backup20160505.ini): Saved vbr config to full_backup20160505.ini.
[dbadmin@localhost ~]$ more password [Passwords] dbPassword = dbadmin 1.2 vertica 全备份 官方文档: A full backupis a complete copy of the databasecatalog, its schemas, tables, and other objects. It is a consistent image of the databaseat the time the backup occurred. You can use a fullbackupfor disaster recoverytorestore a damaged or incomplete database.
执行备份命令:
1 2 3
[dbadmin@localhost ~]$ /opt/vertica/bin/vbr.py --task backup --config-file full_backup20160505.ini Error: Manifest not found at rsync://[192.168.231.110]:50000/home/dbadmin/backup/ -- is the backup location initialized? Hint: Execute '--task init' first. Backup FAILED.
dbadmin=> insert into tb_serv_num values('13488888888','qin**'); OUTPUT -------- 1 (1 row)
dbadmin=> commit; COMMIT dbadmin=> \q
然后重新执行备份语句,执行后查看backup文件下的内容:
1 2 3 4 5 6
[dbadmin@localhost ~]$ cd backup/ [dbadmin@localhost backup]$ ll total 12 -rw-r--r--. 1 dbadmin verticadba 1171 May 5 14:46 backup_manifest drwxr-xr-x. 9 dbadmin verticadba 4096 May 5 14:46 Objects drwxr-xr-x. 4 dbadmin verticadba 4096 May 5 14:46 Snapshots
看文件时间,是不是说明我们上面的推理是正确的呢~~~ 所以,不要怀疑了,我们的增量备份是没有问题的! 1.4 vertica对象级备份 官网文档: The database administrator user can create object-level backups consisting of one or more schemas and tables. Object-level backups are especially useful for multi-tenanted database sites. 其实对象级备份和全量备份差不多,知识在生成备份配置文件时有所不同(注意不同之处):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
[dbadmin@localhost ~]$ /opt/vertica/bin/vbr.py --setupconfigSnapshot name (backup_snapshot): backup_object_tb_serv Number of restore points (1): Specify objects (no default): tb_serv_num Object restore mode (coexist, createOrReplace or create) (createOrReplace): Vertica user name (dbadmin): Save password to avoid runtime prompt? (n) [y/n]: y Database user password to save in vbr password config file (no default): Node v_windy1990_node0001 Backup host name (no default): 192.168.231.110 Backup directory (no default): /home/dbadmin/backup Change advanced settings? (n) [y/n]: Password file name (no default): password Saved vbr password to password. Config file name (backup_object_tb_serv.ini): Saved vbr config to backup_object_tb_serv.ini.
已备份完成~~ 1.5 vertica Hard Link Local备份 官方文档: A hard link local backup is a full or object-level backup consisting of a complete copy of the database catalog, and a set of hard file links to corresponding data files. 直接修改全备份的配置文件即可,加上一行:
dbadmin=> drop table tb_rp_st_user_day; DROP TABLE
dbadmin=> select * from tb_serv_num where name='ss'; serv_num | name -------------+------ 186371***** | ss (1 row)
dbadmin=> delete from tb_serv_num where name='ss'; OUTPUT -------- 1 (1 row)
dbadmin=> commit; COMMIT
开始执行恢复命令:
1 2 3
/opt/vertica/bin/vbr.py --task restore --config-file full_backup20160505.ini [dbadmin@localhost ~]$ /opt/vertica/bin/vbr.py --task restore --config-file full_backup20160505.ini Error: Full database restore requires the nodes be DOWN. Restore FAILED.
报错啦~ 提示只有在vertica数据库down的状态下才能恢复……
查看官方文档:
1 2 3 4 5 6 7
To restore a fulldatabasebackup, you must ensure that: • The databaseis down. You cannot restore a fullbackupwhen the databaseis running. • All of the backuphostsare up and available. • The backupdirectoryexistsand contains the backups from which to restore. • The cluster to which you are restoring the backup has the same numberofhostsas the one used tocreate the backup. The node namesand the IP addresses must also be identical. • The database you are restoring must already exist on the cluster to which you are restoring data. The database can be completely emptywithoutanydataor schema. Aslongas the databasename matches the namein the backup, and all of the node namesmatch the namesof the nodes in the configuration file, you can restoreto it. • The user performing the restoreis the database administrator.