Automating Backup Repository Copy

Product version: 10.0

Last modified: 07 July 2020


How can I automate the copying of a Backup Repository?


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.

  1. Use the command-line interface to find the ID for your Backup Repository by executing the --repository-list command.

  2. Create the pre- and post-job scripts:

    • A pre-job script must attach the Backup Repository.

    • A post-job script must detach the Backup Repository and copy it to the USB drive.

  3. Place the pre- and post-job scripts in the bin folder in the product installation folder.

  4. 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.

  5. Schedule your backup job or run it on demand.
    The scripts will trigger the copying of the entire repository content after each job run.


  • 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:


CD "C:\Program Files\NAKIVO Backup & Replication\bin"CALL "C:\Program Files\NAKIVO Backup & Replication\bin\cli.bat" --repository-attach 1


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