Automating Backup Repository Copy
Product version: 10.0
Last modified: 07 July 2020
Question
How can I automate the copying of a Backup Repository?
Answer
You can use a backup copy job to copy your backups.
The following example describes the procedure for copying a Backup Repository to a USB drive with NAKIVO Backup & Replication installed on Windows.
-
Use the command-line interface to find the ID for your Backup Repository by executing the
--repository-list
command. -
Create the pre- and post-job scripts:
-
Place the pre- and post-job scripts in the
bin
folder in the product installation folder. -
Edit your backup job to run the above-mentioned pre- and post-job scripts.
The job must be set to wait for the pre-job script to complete and should fail if the script fails. -
Schedule your backup job or run it on demand.
The scripts will trigger the copying of the entire repository content after each job run.
Note
The Backup Repository must be detached while copying the contents.
You can use the same approach to copy the Backup Repository to a shared folder at another server.
Script Examples
Below you can find Windows script examples that copy the Backup Repository using the Robocopy tool. For Linux-based NAKIVO Backup & Replication deployments, we recommend using the Rsync utility.
In the current example, we assume that:
-
The Backup Repository is located in the root of C: drive.
In this case, the backups will be located in the C:\NakivoBackup folder. -
The ID of the Backup Repository is 1.
-
The secondary location is USB drive F:
pre-job.bat
CD "C:\Program Files\NAKIVO Backup & Replication\bin"CALL "C:\Program Files\NAKIVO Backup & Replication\bin\cli.bat" --repository-attach 1
post-job.bat
CD "C:\Program Files\NAKIVO Backup & Replication\bin"CALL "C:\Program Files\NAKIVO Backup & Replication\bin\cli.bat" --repository-detach 1 robocopy "C:\NakivoBackup" "F:\NakivoBackup" /mir /z /is /r:10 /w:15 /nfl /ndl