Vertica uses vbr.py tools that is written in python. This utility lets you create full and incremental database snapshots, as well as snapshots of specific schema's or tables for use with a multitenant database. You can run the Vertica vbr.py from a crontab job or other task scheduler.
SELECT SET_CONFIG_PARAMETER('RemoveSnapshotInterval',7200);
select sum(used_bytes) as total_size from v_monitor.storage_containers;
select node_name,sum(used_bytes) as size_in_bytes from v_monitor.storage_containers group by node_name;
#vbr.py --setupconfig
vbr.py --setupconfig
Snapshot name (snapshotName): ExampleBackup
Backup Vertica configurations (n) [y/n] y
Number of restore points (1): 5
Specify objects (no default): dim, dim2
Vertica user name (current_user): dbadmin
Save password to avoid runtime prompt (n)[y/n]: y
Password to save in vbr config file (no default): mypw234
Node v_example_node0001
Backup host name (no default): backup01
Backup directory (no default): /home/dbadmin/backups
Node #1
Node name: v_exampledb_node0002
Backup host name: backup02
Backup directory: /home/dbadmin/backups
Node #2
Node name: v_exampledb_node0003
Backup host name: backup03
Backup directory: /home/dbadmin/backups
Config file name: exampleBackup.ini
Change advanced settings (n)[y/n]: n
Saved vbr configuration to exampleBackup.ini.
/opt/vertica/bin/vbr.py -ask backup -onfig-file
/opt/vertica/bin/vbr.py task restore --config-file
$ /opt/vertica/bin/vbr.py setupconfig
Snapshot name (snapshotName): --It is the name of the SnapShot
Backup Vertica configurations (n) [y/n] y default is false (will backup
configuration file as well)
Number of restore points (1): -default is 1 but can be from 1-99 (it repsents the
number of snapshots to retain. Having multiple snapshots
allows us to create incremental backups.
If the value is 1(default) then the backup will overwrite.
Specify objects (no default): - default is none , you can specify the names of the
specific objects you want to include in a backup.
You need to list the objects separated by comma .
Non-alphanumeric characters, use a backslash () followed by a hex value.
Example:
Object name my table
You can listed like this :
Objects=my20table,objectname,etc
Vertica user name (current_user): -is the admin user in this case, who can run the
Backup/restore tasks.
Save password to avoid runtime prompt (n)[y/n]:-chose to save the password in the
backup config file or now, by default is not.
Password to save in vbr config file (no default):- if you chose to store the passwd
In the backup config file then you must specify it now.
Backup host name (no default): - indicates where the backup will be stored, can be
on one of the cluster hosts or another host outside the
cluster(user must have password-less ssh access and specific
rights on the host).
Backup directory (no default):- full path location of the backup storage place.
Directory must already exist and must be writable by the user that
runs the backup utility.
Config file name: - it is the name of the backup configuration exampleBackup.ini
Change advanced settings (n)[y/n]: -chose to configure advanced settings, default
value is alse
Config file name: /opt/vertica/backupConf/exampleBackup.ini
Change advanced settings (n)[y/n]:Y
What are the options:
Temp directory (/tmp/vbr):
- absolute path to a temporary storage area on the cluster nodes.(default value tmp
Note: The tmp path must be the same on all nodes in the cluster.
Number of times to retry (2):
- repsentes the number of times the backup operation attempts to
complete execution after an error occurs. If the failure continues to occur
after the number of retry attempts, the utility reports an error and stops processing.
Seconds between retry attempts (1):
- number of seconds to wait between backup retry attempts in the event of a failure.
Encrypt data during transmission (n) [y/n]:
- default value is false. Choose this option if you are performing a backup over an
untrusted network (for example, backing up to a remote host across the Internet).
Note:
- Encrypting data transmission causes significant processing overhead and slows transfer.
Use checksum for data integrity (not file date and size) (n) [y/n]:
- default value is false.
- determine whether files are identical before and after network transmission.
Note: Calculating checksum values increases processor usage during the backup process.
Port number for rsync daemon (50000):
-default value is 50000
-you change the port number of the rsync as desired/needed.
Transfer bandwidth limit in KBps or 0 for unlimited (0):
- Indicates the transfer bandwidth limit.
- by default is has no limit.
[root@Vertica_Master1 /]# rm -rf /vertica_db/
[root@Vertica_Master1 /]# mkdir -p /vert_backup/backup
[root@Vertica_Master1 /]# cd /vert_backup/
[root@Vertica_Master1 vert_backup]# mkdir backup_conf
[root@Vertica_Master1 vert_backup]# cd /
[root@Vertica_Master1 /]# chown -R dbadmin:dbadmin /vert_backup/
[dbadmin@Vertica_Master1 cluster]$ vbr.py --setupconfig
Snapshot name (backup_snapshot): full_backup
Backup vertica configurations (n) [y/n]: y
Number of restore points (1):
Specify objects (no default):
Vertica user name (dbadmin): dbadmin
Save password to avoid runtime prompt (n) [y/n]: n
Node v_cluster_node0001
Backup host name (no default): 10.253.1.216
Backup directory (no default): /vert_backup/backup
Node v_cluster_node0002
Backup host name (no default): 10.253.1.216
Backup directory (no default): /vert_backup/backup
Node v_cluster_node0003
Backup host name (no default): 10.253.1.216
Backup directory (no default): /vert_backup/backup
Config file name (full_backup.ini): /vert_backup/backup_conf/full_backup.ini
Change advanced settings (n) [y/n]: n
Saved vbr configuration to /vert_backup/backup_conf/full_backup.ini.
[dbadmin@Vertica_Master1 cluster]$
[dbadmin@Vertica_Master1 cluster]$
[dbadmin@Vertica_Master1 cluster]$
[dbadmin@Vertica_Master1 cluster]$ cd /vert_backup/backup_conf/
[dbadmin@Vertica_Master1 backup_conf]$ ls -la
total 4
-rw-rw-r--. 1 dbadmin dbadmin 475 Sep 6 14:00 full_backup.ini
[dbadmin@Vertica_Master1 backup_conf]$ vbr.py --setupconfig
Snapshot name (backup_snapshot): backup_incremental_7
Backup vertica configurations (n) [y/n]: y
Number of restore points (1): 7
Specify objects (no default):
Vertica user name (dbadmin): dbadmin
Save password to avoid runtime prompt (n) [y/n]: n
Node v_cluster_node0001
Backup host name (no default): 10.253.1.216
Backup directory (no default): /vert_backup/backup
Node v_cluster_node0002
Backup host name (no default): 10.253.1.216
Backup directory (no default): /vert_backup/backup
Node v_cluster_node0003
Backup host name (no default): 10.253.1.216
Backup directory (no default): /vert_backup/backup
Config file name (backup_incremental_7.ini): /vert_backup/backup_conf/backup_incremental_7.ini
Change advanced settings (n) [y/n]: n
Saved vbr configuration to /vert_backup/backup_conf/backup_incremental_7.ini.
[dbadmin@Vertica_Master1 backup_conf]$
[dbadmin@Vertica_Master1 backup_conf]$
[dbadmin@Vertica_Master1 backup_conf]$ ls -la
total 16
drwxr-xr-x. 2 dbadmin dbadmin 4096 Sep 6 14:05 .
drwxr-xr-x. 4 dbadmin dbadmin 4096 Sep 6 13:40 ..
-rw-rw-r--. 1 dbadmin dbadmin 470 Sep 6 14:05 backup_incremental_7.ini
-rw-rw-r--. 1 dbadmin dbadmin 475 Sep 6 14:04 full_backup.ini
cluster= dt
List of tables
Schema | Name | Kind | Owner | Comment
--------+-------+-------+---------+---------
public | one | table | dbadmin |
public | three | table | dbadmin |
public | two | table | dbadmin |
(3 rows)
[dbadmin@Vertica_Master1 /]$ vbr.py --setupconfig
Snapshot name (backup_snapshot): backup_table.one
Backup vertica configurations (n) [y/n]: n
Number of restore points (1):
Specify objects (no default): public.one
Vertica user name (dbadmin): dbadmin
Save password to avoid runtime prompt (n) [y/n]: n
Node v_cluster_node0001
Backup host name (no default): 10.253.1.216
Backup directory (no default): /vert_backup/backup
Node v_cluster_node0002
Backup host name (no default): 10.253.1.216
Backup directory (no default): /vert_backup/backup
Node v_cluster_node0003
Backup host name (no default): 10.253.1.216
Backup directory (no default): /vert_backup/backup
Config file name (backup_table.one.ini): /vert_backup/backup_conf/backup_table_one.ini
Change advanced settings (n) [y/n]: n
Saved vbr configuration to /vert_backup/backup_conf/backup_table_one.ini.
[dbadmin@Vertica_Master1 /]$
[dbadmin@Vertica_Master1 /]$
[dbadmin@Vertica_Master1 /]$
[dbadmin@Vertica_Master1 /]$ cd /vert_backup/backup_conf/
[dbadmin@Vertica_Master1 backup_conf]$ ls -la
total 20
drwxr-xr-x. 2 dbadmin dbadmin 4096 Sep 6 14:21 .
drwxr-xr-x. 4 dbadmin dbadmin 4096 Sep 6 13:40 ..
-rw-rw-r--. 1 dbadmin dbadmin 470 Sep 6 14:12 backup_incremental_7.ini
-rw-rw-r--. 1 dbadmin dbadmin 488 Sep 6 14:21 backup_table_one.ini
-rw-rw-r--. 1 dbadmin dbadmin 475 Sep 6 14:04 full_backup.ini
# vbr.py task backup --config-file
# vbr.py task restore --config-file
[dbadmin@Vertica_Master1 backup_conf]$ vbr.py --task backup --config-file full_backup.ini
Please input vertica password:
pparing...
Found Database port: 5433
Copying...
251955 out of 251955, 100%
All child processes terminated successfully.
Committing changes on all backup sites...
backup done!
[dbadmin@Vertica_Master1 backup_conf]$ vbr.py --task backup --config-file backup_incremental_7.ini
Please input vertica password:
pparing...
Found Database port: 5433
Copying...
249828 out of 249828, 100%
All child processes terminated successfully.
Committing changes on all backup sites...
backup done!
[dbadmin@Vertica_Master1 backup_conf]$ vbr.py --task backup --config-file backup_table_one.ini
Please input vertica password:
pparing...
Found Database port: 5433
Copying...
70926 out of 70926, 100%
All child processes terminated successfully.
Committing changes on all backup sites...
backup done!
[dbadmin@Vertica_Master1 /]$ cd vert_backup/
[dbadmin@Vertica_Master1 vert_backup]$ ls -la
total 16
drwxr-xr-x. 4 dbadmin dbadmin 4096 Sep 6 13:40 .
dr-xr-xr-x. 28 root root 4096 Sep 6 13:53 ..
drwxr-xr-x. 5 dbadmin dbadmin 4096 Sep 6 15:22 backup
drwxr-xr-x. 2 dbadmin dbadmin 4096 Sep 6 15:29 backup_conf
[dbadmin@Vertica_Master1 vert_backup]$ cd backup/
[dbadmin@Vertica_Master1 backup]$ ll
total 12
drwxrwxr-x. 8 dbadmin dbadmin 4096 Sep 6 15:29 v_cluster_node0001
drwxrwxr-x. 8 dbadmin dbadmin 4096 Sep 6 15:29 v_cluster_node0002
drwxrwxr-x. 8 dbadmin dbadmin 4096 Sep 6 15:29 v_cluster_node0003
[dbadmin@Vertica_Master1 backup]$ cd v_cluster_node0001/
[dbadmin@Vertica_Master1 v_cluster_node0001]$ ll
total 12
drwx------. 3 dbadmin dbadmin 4096 Sep 6 15:26 backup_incremental_7
drwx------. 3 dbadmin dbadmin 4096 Sep 6 15:29 BackupTableOne
drwx------. 3 dbadmin dbadmin 4096 Sep 6 15:22 full_backup
#vbr.py task restore --config-file
cluster= dt
List of tables
Schema | Name | Kind | Owner | Comment
--------+-------+-------+---------+---------
public | one | table | dbadmin |
public | three | table | dbadmin |
public | two | table | dbadmin |
(3 rows)
cluster= drop table one,two,three;
DROP TABLE
cluster= dt
No relations found.
[dbadmin@Vertica_Master1 backup_conf]$ vbr.py --task restore --config-file full_backup.ini
Please input vertica password:
Preparing...
Found Database port: 5433
Warning: trying to restore to an UP cluster
Warning: Node state of v_cluster_node0001 is UP; node must be DOWN for restore; ignoring restore on this node.
Warning: Node state of v_cluster_node0002 is UP; node must be DOWN for restore; ignoring restore on this node.
Warning: Node state of v_cluster_node0003 is UP; node must be DOWN for restore; ignoring restore on this node.
Nothing to do
restore done!
[dbadmin@Vertica_Master1 backup_conf]$ vbr.py --task restore --config-file full_backup.ini
Please input vertica password:
Preparing...
Found Database port: 5433
Copying...
248556 out of 248556, 100%
All child processes terminated successfully.
restore done!
cluster= dt
List of tables
Schema | Name | Kind | Owner | Comment
--------+-------+-------+---------+---------
public | one | table | dbadmin |
public | three | table | dbadmin |
public | two | table | dbadmin |
(3 rows)
cluster= drop table one;
DROP TABLE
cluster= dt
List of tables
Schema | Name | Kind | Owner | Comment
--------+-------+-------+---------+---------
public | three | table | dbadmin |
public | two | table | dbadmin |
(2 rows)
[dbadmin@Vertica_Master1 backup_conf]$ vbr.py --task restore --config-file backup_table_one.ini
Please input vertica password:xxxxxxxx
Preparing...
Found Database port: 5433
Copying...
0 out of 0, 100%
All child processes terminated successfully.
Copying...
2763 out of 2763, 100%
All child processes terminated successfully.
restore done!
[dbadmin@Vertica_Master1 backup_conf]$ vsql
Password:xxxxxxx
dbadmin= dt
List of tables
Schema | Name | Kind | Owner | Comment
--------+-------+-------+---------+---------
public | one | table | dbadmin |
public | three | table | dbadmin |
public | two | table | dbadmin |
(3 rows)
dbadmin= d one ;
List of Fields by Tables
Schema | Table | Column | Type | Size | Default | Not Null | Primary Key | Foreign Key
--------+-------+--------+--------------+------+---------+----------+-------------+-------------
public | one | one | numeric(3,0) | 8 | | f | f |
# Minute Hour Day of Month Month Day of Week Command
# (0-59) (0-23) (1-31) (1-12 or Jan-Dec) (0-6 or Sun-Sat)
0 2 12 * 0,6 /usr/bin/find
0 1 * * * /opt/vertica/bin/vbr.py task backup --config-file /vertica_db/backup_conf/ Incremental_full /vertica_db/backup/cronjobs.log