PowerShell script exchange
Post Reply
diverge
Novice
Posts: 4
Liked: 2 times
Joined: Jul 25, 2014 9:28 pm
Contact:

Script to switch between backup locations

Post by diverge »

I am writing a script effectively to switch a copy backup to backup to a different file location. It would run each week and select from about 10 different possible locations on different backup disks (not all at the same file path). A newly selected backup folder would be cleared, so thanks to the ForceCreateMissingVBK Veeam should start a new chain for the week.

It seems that it is not possible to script a change of repository or to change the path of a repository. Is that correct?

The two options I have been considering instead are:
  • Have a separate repository and backup copy job for each location. The script would enable the one required for the week. This would require managing quite a number of jobs.
  • Create a new repository and backup job each week for the new location. Would it cause any issues (eg database clutter) to be deleting and creating backup jobs on such a regular basis?
I wondered if anyone had any thoughts on the best solution, or saw any issues I had not considered.
veremin
Product Manager
Posts: 20271
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Script to switch between backup locations

Post by veremin »

You're right. Currently, it's not possible to switch repository in the settings of backup/backup copy jobs.

Both scenarios should work fine, but I'm wondering whether 10 disks you're talking about are located within one server. In the latter case, you can probably specify remote folder as a target for backup copy job, and set a hard link to it. Each week within the script you will update the link pointing it to the required disk.

Thanks.
diverge
Novice
Posts: 4
Liked: 2 times
Joined: Jul 25, 2014 9:28 pm
Contact:

Re: Script to switch between backup locations

Post by diverge »

Thank you for the confirmation, v.Eremin.

I will look into the hard link idea, but I think it will not work because backup folders are on removable hard drives. The reason for using the script rather than just mounting them all at the same drive letter is that there may be several backups per drive and may be a couple of disks connected at one time.
veremin
Product Manager
Posts: 20271
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Script to switch between backup locations

Post by veremin »

So, you're saying that the different disks are mounted under different drive letters, right? In this case, you can create a folder on a system drive that isn't swapped at all, assign repository role to it, and within a script create a hardlink to whatever drive that corresponds to a current week.

1 Week: C:\Repository -link-> D:\
2 Week: C:\Repository -link-> E:\
----------------etc.-------------------

Thanks.
diverge
Novice
Posts: 4
Liked: 2 times
Joined: Jul 25, 2014 9:28 pm
Contact:

Re: Script to switch between backup locations

Post by diverge » 1 person likes this post

I have now had a chance to test your idea, v.Eremin, and it seems to work well. I used a symlink rather than a hardlink, as those do not work across drives. Veeam does not seem to have any problem with using a symlink as repository location. Nothing too terrible seems to happen if the drive is ejected without the symlink being removed.

Thank you for your help.
veremin
Product Manager
Posts: 20271
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Script to switch between backup locations

Post by veremin »

Glad to hear that my input was helpful. Should other questions arise, don't hesitate to ask. Thanks.
diverge
Novice
Posts: 4
Liked: 2 times
Joined: Jul 25, 2014 9:28 pm
Contact:

Re: Script to switch between backup locations

Post by diverge » 1 person likes this post

I have a warning for anyone else attempting this approach. While Veeam appears to back up to a symbolic link path (eg C:\LinkToExternal) without a problem, the initial setup of the backup repository will automatically resolve the link to the current target location (eg F:\PathOnExternalDisk) and use that instead. You can get around this by initially putting a normal folder at the symbolic link's location (C:\LinkToExternal) and then swapping it for a symbolic link (to F:\PathOnExternalDisk) after the backup repository has been created.
veremin
Product Manager
Posts: 20271
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Script to switch between backup locations

Post by veremin »

Yep, that was my point. Create a folder, assign repository role to it, and add/modify symbolic link afterwards either manually or automatically via script. Anyway, thank you for sharing the warning and results of your findings; much appreciated.
Post Reply

Who is online

Users browsing this forum: No registered users and 23 guests