Script to switch between backup locations

PowerShell script exchange

Script to switch between backup locations

Veeam Logoby diverge » Fri Jul 25, 2014 10:23 pm

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.
diverge
Novice
 
Posts: 4
Liked: 2 times
Joined: Fri Jul 25, 2014 9:28 pm

Re: Script to switch between backup locations

Veeam Logoby v.Eremin » Mon Jul 28, 2014 8:25 am

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.
v.Eremin
Veeam Software
 
Posts: 13281
Liked: 970 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Script to switch between backup locations

Veeam Logoby diverge » Tue Jul 29, 2014 8:54 pm

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.
diverge
Novice
 
Posts: 4
Liked: 2 times
Joined: Fri Jul 25, 2014 9:28 pm

Re: Script to switch between backup locations

Veeam Logoby v.Eremin » Wed Jul 30, 2014 8:25 am

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.
v.Eremin
Veeam Software
 
Posts: 13281
Liked: 970 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Script to switch between backup locations

Veeam Logoby diverge » Sat Aug 09, 2014 2:09 pm 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.
diverge
Novice
 
Posts: 4
Liked: 2 times
Joined: Fri Jul 25, 2014 9:28 pm

Re: Script to switch between backup locations

Veeam Logoby v.Eremin » Mon Aug 11, 2014 7:25 am

Glad to hear that my input was helpful. Should other questions arise, don't hesitate to ask. Thanks.
v.Eremin
Veeam Software
 
Posts: 13281
Liked: 970 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Script to switch between backup locations

Veeam Logoby diverge » Sun Sep 07, 2014 5:36 pm 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.
diverge
Novice
 
Posts: 4
Liked: 2 times
Joined: Fri Jul 25, 2014 9:28 pm

Re: Script to switch between backup locations

Veeam Logoby v.Eremin » Mon Sep 08, 2014 9:13 am

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.
v.Eremin
Veeam Software
 
Posts: 13281
Liked: 970 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 4 guests