Options

Trying to run vertica backup through crontab

I have a 3 node cluster. I have configured the backup and when I run it directly it runs fine. But when I use crontab and schedule it, backup doesn't run. Below is the crontab, the output file which is created at the scheduled time but is empty.Please help as I have to set backup in prod environment at a regular interval

 

$ crontab -l
20 15 * * * nohup vbr.py --task backup --config-file backup_snapshot.ini > backup.out &

 

ls -ltr

-rw-r--r-- 1 dbadmin verticadba 0 Oct 1 15:20 backup.out

 

$ cat backup.out
]$

 

 

Below is the backup config file:

 

vbr.py --setup config
Snapshot name (backup_snapshot):
Number of restore points (1):
Specify objects (no default):
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_verticadb_node0001
Backup host name (no default): node1
Backup directory (no default): /home/dbadmin/bkp
Node v_verticadb_node0002
Backup host name (no default): node2
Backup directory (no default): /home/dbadmin/bkp2
Node v_verticadb_node0003
Backup host name (no default): node3
Backup directory (no default): /home/dbadmin/bkp3
Config file name (backup_snapshot.ini):
Password file name (no default value) (no default): passwdfile
Change advanced settings? (n) [y/n]: n
Saved vbr configuration to backup_snapshot.ini.
Saved vbr configuration to passwdfile.

 

i have transfered the passwdfile to the other two nodes in /home/dbadmin location

Comments

  • Options

     I have tryed that myself and is not working as well. 

    Maybe this might help you.

    Why not use a UDP to dynamically create your backup config and run it from inside Vertica ?

    Here is how i do it. (This is just for the schema backup).

     - is the same principale as running it as a corntab job

    1- Create a template backup.ini config file:

    - example 

     

    [Misc]
    snapshotName = schema_name
    verticaConfig = True
    restorePointLimit = 1
    objects = schema_name
    tempDir = /vertica_storage
    retryCount = 2
    retryDelay = 1
    [Database]
    dbName = db_name
    dbUser = dbadmin
    dbPassword = password
    [Transmission]
    encrypt = False
    checksum = False
    port_rsync = 50000
    bwlimit = 0
    [Mapping]
    v_analytics_node0004 = 101.11.431.111:/vertica_storage/backup
    v_analytics_node0005 = 101.11.431.112:/vertica_storage/backup
    v_analytics_node0006 = 101.11.431.113:/vertica_storage/backup

    Note:

     

    - you got to make sure your got your locaitons and password variable in place.

     

     

    2 - Create the shell script the you will call as your UDP

      - place this file in your 

      /vertica/catalog/db_name/procedures/schema_backup.sh

     

    #!/bin/bash

    export DATE=`date +"%m-%d-%y"`

    cat /tmp/adi/schema_backup_template.ini | sed 's/schema_name/'$1'/g' > /tmp/adi/replace/$1-schema-backup$DATE.ini
    /opt/vertica/bin/vbr.py --task backup --config-file /tmp/adi/replace/$1-schema-backup$DATE.ini
    exit 0;

     - alter the file

     

    chmod 777  /vertica/catalog/db_name/procedures/schema_backup.sh
    chmod u+s  /vertica/catalog/db_name/procedures/schema_backup.sh

     

     

    3 - Create the procedure

     

    CREATE PROCEDURE schema_backup(schema_name varchar(100)) as 'schema_backup.sh' language 'external' USER 'dbadmin';

    4 - Run the procedure

     

    -let`s says you wanna bkp schema dev, you just run this line of code.

     

    select schema_backup('dev');

     

     

     - this will create a new ini file in the /tmp/adi/replace folder following the rules we placed in the schema_backup.sh and will execute the new ini config file.

    - you can also populate the dbPassorwd value with a variable coming from a single stored place. so no string password will be needed.

     

    - i like to do it like this becouse i don`t have to write code for every schema(schemas come and go) and also this  procedure can be a part of a dinamic query that will execute backup on only the schemas i want.(you will need separate tool for this eg: informtica or even mstr).

     

    -you can do this with tables or even the entire database.

     

    I hope this helps you or anybody reading it.

     

     

     

     

     

  • Options

    Actually my issue got fixed when I give the whole location in crontab instead of just vbr.py.

     

     

  • Options

     Great.. Why make it easy ?! when we can make it complicated !!! hehehehe

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file