Thursday, 21 June 2018 12:55

BackupPC and Volume Shadow Copy Services (VSS)

Rate this item
(0 votes)

BackupPC can be a very daunting task when first starting out, but as many people who have installed it multiple times will say, it's not that bad, but it does take some time to figure out.  One of my sayings (as I may have said before), "It's easy, if you know how to do it," meaning it's not easy, if you don't. :)  BackupPC is one of them, but don't fear, if you work through the issues, you'll make it. Additionally, my plan is to write my notes how I install it in a future post.

For those that get it running, the first thing they'll notice is that it doesn't copy open files.  So, for those computers where the backup begins and people are working on stuff, open files are not backed up, i.e., Outlook Files or open Office documents.  This bugged me because I was and I am a BackupPC fan.  I scoured the internet in search of an easy way (emphasis on easy) to have BackupPC copy open files on Windows Computers.  Well, in my search, I didn't find an easy one, so I went on a development spree to try and figure out a way to do it.  It took a few weeks of trial and error, but I can now say, there is an easy way to do it.

Over the years, what I did grew into a hodge podge of files in a folder and a few batch files.  These past few weeks, I decided to try and put them together into one interface.  I wanted to use AutoIt, but the compressed executable, although doesn't have viruses, is flagged by many Antivirus programs as having one just because it was compressed by AutoIt.  I didn't want to keep answering the question, "Does it contain viruses," so I opted to use Visual Basic, instead.  So, below is what has been developed.  From my experience, this solution runs on anything after Windows 7.  I've, successfully, run this solution on Windows 7/8/10 without problems.

This is the first version of the GUI, so there may be a few bugs. If you find one or more, please post it in the comments below.

Additionally, I uploaded the exe's to VirusTotal.com.  They have passed all virus checks.  I would encourage you to do the same, if you decide to use these files.  I can, personally, attest that I did not write any backdoors nor viruses in these files.  These are clean and feel free to use them, if you like.

 

 VSSBackupPC 1.1

 

VSSBackupPC is designed to be used with the BackupPC server software.  This app uses Volume Shadow Copy Services so the server can backup open files on the C:\ drive.  To accomplish this, it uses Cygwin and Rsync for the data transfer.

I tried to make this as easy as possible.  I know it's a lot of writing below, but, in reality, there are only a few settings.

This app is written in Visual Basic and the .Net Framwork version 4.6.1 is needed to run it.

The Welcome window

Select the resource zip file that is included in the download.

The contents of the resource file is below.

When the app is started, it creates a folder called: C:\rsyncd.   This is a hard coded folder and cannot be changed.

All files related to this app will be created and placed in this folder.
 

Rsyncd.secrets

Enter the rsync user name and password.  It should be the same as used on the BackupPC server in these fields: RsyncdUserName, RsyncdPassword


As you hover over the window, if a secret file is found, it will display: Secrets File Exists.  If not, it displays: No Secrets File

Click the Add button to create the file and/or add credentials to an existing one

To find more information about the secrets file, check the client setup on the BackupPC website.

 

Rsyncd.Conf

See samba.org website for more information about this file.

1.  RsyncShareName = [Module Name]

Should be the same as the one added in BackupPC. Case matters, so UserFolder and userfolder are different.

2.  Choose the Local Backup Path.

Do Not Use VSS: Checking this box will force BackupPC to use the actual folder and will not copy open files.  At this point, drives other than C: are not included in the Shadow folder.

3.  Comment:  A short comment, like "User Folder"

4.  BackupPC Server IP Address: The ‘Allowed host(s)’ to access the PC and run rsync remotely

Strict Modes, Read Only, and List: Consult the samba website above for more information

As you hover over the window, if a rsync.conf file is found, it will display: Conf File Exists.  If not, it displays: No Conf File

5.  ‘Load Defaults’ will place default values in the fields and check boxes.  Edit the RsyncShareName, Host IP Address, and/or Path.  Then, you're set.

 

 
Manually Edit Rsyncd.Conf

You can manually edit the rsyncd.conf file.  This is not necessary nor encouraged, but is built-in to help with advanced configurations.
 

Task Settings

1.  Renew VSS Folder every 'x' hours

Default = 6 hours.   Set the time (in hours) that the script looks at the Time Stamp on the Shadow folder. When the time has exceeded, the Shadow Folder is removed and recreated.

2.  Only Allow VSS Backup Tasks to Run on AC Power?

Default = Yes.   To allow the VSSBackukpPC scheduled tasks to run if the laptop is running on batteries, uncheck the box.  If checked, the Scheduled Tasks will only run while the computer is plugged in.  (Thanks to agu for finding this setting)

 

Install Services

1.  Type the Host IP Network.  Only type the first three octets of the network.  There are a few drop down examples, but you can type any IP address that is needed.1  For example:
192.168.1
172.16.0
10.0.0

2.  Select the Subnet Mask of the Network.  The default is 24 (255.255.255.0).

3. ‘Install Services.  This will open two command windows and install the services needed to run VSSBackupPC.

4.  If needed, the ‘Remove Services’ button will remove the services so the C:\rsyncd folder can be deleted.

When VSSBackupPC starts, it checks for a running process of rsync on startup.  If it finds one, it will display a message asking to remove the service if it needs to be installed again.  You do not have to remove the service if you only need to change the secrets or conf file.

1This network is added to the Private firewall profile to allow port 873 and pings through it. The script does not change the public profile in any way so make sure the computer is in the private firewall profile

 
The resource zip file contains 8 files as seen to the right.  The Cygwin files can be found on the internet as well as the vshadow,exe file.  removevss.exe and vss-backuppc.exe were written in Visual Basic to handle the logic.

All files have been uploaded and checked at VirusTotal.com.  Feel free to upload them to check yourself.  There are no Viruses or Backdoors written in the code.
 

There is one, additional, thing you have to do on the BackupPC server, but it's not difficult.

1.  Add a DumpPreUserCmd script to the BackupPC server.

Create a folder that is accessible by the backuppc user, for example, choose to create a 'scripts' subfolder where backuppc resides

In the folder, create two files:

  1. preshare.sh
  2. pass

2. preshare.sh:    Replace <Enter_Secrets_File_UserName> with the user name used above in the secrets file.

3.  pass  (used in preshare.sh):  Enter the secrets password used in the secrets file. Nothing else, no brackets, etc.

4.  In the DumpPreUserCmd field, type:

sh + the path to the preshare.sh + space + $host

Ex: sh /media/backup/scripts/preshare.sh $host

 

 

1.  preshare.sh:
---------------------
#!/bin/bash
echo "I am the dumppresharecmd for BackupPC..."
echo "======================================="
 
rsync --dry-run --password-file=/media/backup/scripts/pass rsync://<Secrets_File_UserName>@$1/cDrive

#Ex. rsync --dry-run --password-file=/media/backup/scripts/pass rsync://SUser@$1/cDrive

echo "Waiting 60 seconds.  Giving time to create shadow copy"
sleep 60
echo "all Done."
echo "======================================"

 


2.  pass
---------------------
# =======================
Secrets_File_Password
#Ex.   mysecretpass
# =======================

 

Some notes:

A VSS folder called c:\shadow is created.  This is where BackupPC is directed. 

Additionally, the script creates a logfile called: vsslog.log and is found in the C:\rsyncd folder.  When the logfile reaches 2MB, it is deleted and recreated.

I hope this makes sense and may even help someone down the road.  If there are any questions, bugs, or comments, leave them below.

As always, enjoy!

VSSBackupPC.exe and the resource.zip file can be downloaded here: VSSBackupPC.zip

 

Read 2939 times Last modified on Saturday, 27 April 2019 00:34

19 comments

  • Comment Link etienne gallant Wednesday, 03 October 2018 12:26 posted by etienne gallant

    Bonjour,

    Your script is very fine. But I have an issue : the vss command don't start ...
    what is the cygwin command to start it before to execute your preshare script ?
    Thanks for answer
    Etienne

    Report
  • Comment Link Admin Thursday, 04 October 2018 21:27 posted by Admin

    Bonjour!
    I looked, and realized, you are right, the service is not starting. I'll post an update here. Sorry.

    Report
  • Comment Link Admin Thursday, 11 October 2018 13:36 posted by Admin

    I took a few minutes to figure this out. If the service is not starting, it could be a number of issues. The way to figure out what it is is to edit the C:\rsyncd\rsyncd.conf file and look for the following:

    ---------------
    #
    # Only uncomment temporary to debug rsync. Commenting this line
    # is essential for the VSS to work properly
    #
    #log file = c:/rsyncd/rsyncd.log
    ---------------
    Uncomment the log file line by removing the '#'.
    Open an Administrator Command Prompt
    Type:
    C:\rsyncd\cygrunsrv.exe --start rsyncd

    If the service doesn't start, look at the rsyncd.log file for more details. Once you have the service running, open C:\rsyncd/rsyncd.conf and comment the log file line by placing the '#' in front of the line again.

    If help is still needed, paste the contents of the rsyncd.log file and I'll take a look.

    --The two errors I ran into were:
    Another rsync service was using port 873
    Solution: Stop the service from automatically starting
    PID file in use:
    Solution: Delete the .pid file located in C:\rsyncd

    Enjoy!

    Report
  • Comment Link Admin Thursday, 18 October 2018 00:14 posted by Admin

    Well, i found the bug. The service wasn't deleting the pid file when the computer restarted.
    I've fixed it and have uploaded a new version today.
    Thank you for the comment and post here if anyone has any other trouble.

    Report
  • Comment Link sriram Saturday, 12 January 2019 11:10 posted by sriram

    dear Admin,
    we need to backup open file for that need your support with step by step both server side and client side configuration please.

    Report
  • Comment Link Admin Sunday, 13 January 2019 21:04 posted by Admin

    @sriram
    The client file above is used for Windows PCs after the BackupPC server is running properly. If you have a BackupPC server running and the VSSBackupPC client isn't working, please post the error logs you receive (see post above on Thursday, 11 October 2018).

    I'll try and post how to get a BackupPC server working on linux in the next month, but I don't have that ready yet.

    Thanks

    Report
  • Comment Link Agu Monday, 04 February 2019 23:28 posted by Agu

    Hi great job.
    I would like to ask if sources are available. I would like to learn how you trigger de shadow copy creation remotely and how you map the snapshot to a folder.
    Thanks

    Report
  • Comment Link Agu Tuesday, 05 February 2019 03:48 posted by Agu

    Hi, I installed the application but when I restart the system, rsyncd is stopped due to the PID file not getting erased. If I manually delete it, then I can start the service but when I restart the system, I experience the same situation. How can I enable the automatic deletion of the PID file?
    I have also observed that even if the line in rsyncd.conf about log file is commented out, a log file is always created at c:/var/log/. Is that OK?
    Thank you.

    Report
  • Comment Link Admin Tuesday, 05 February 2019 11:54 posted by Admin

    @Agu
    I don't have the source code available at this point. That can be on my list for a future post, but the script is fired by looking at the Event Log.

    For the PID file problem, would you mind restarting the computer and then paste the contents of the vsslog.log file from the time you started the computer until you are logged in? That would help me troubleshoot what the problem may be.

    Thank you for giving this a try!

    Report
  • Comment Link Agu Tuesday, 05 February 2019 21:08 posted by Agu

    Hi,

    *1*) I uninstalled and then reinstalled the application ("Remove Services" button + erase files) and got same behaviour. I tried one more time and this time it worked. Now it is deleting PID file at startup. I don t know what was different between the three installations, but now it works. Below I paste the logs I found in vsslog at startup (before vs now)

    This corresponds to the first installation, when PID file wasn't being erased:

    2/4/2019 10:05:50 PM -- Starting Script...
    2/4/2019 10:05:50 PM -- No Processes found. Rsync is not running.

    And this is the third installation that seems to be working:

    5/2/2019 12:06:59 -- No Processes found. Rsync is not running. - removevss
    5/2/2019 12:06:59 -- Removing rsyncd.pid and restarting.
    5/2/2019 12:06:59 -- Stopping Service.
    5/2/2019 12:06:59 -- Removed rsyncd.pid.
    5/2/2019 12:06:59 -- Starting Service.
    5/2/2019 12:06:59 -- Shadow folder does not exist. Not removing it.
    2/5/2019 12:07:29 PM -- Starting Script...
    2/5/2019 12:07:29 PM -- More than 1 Processes found.
    2/5/2019 12:07:29 PM -- 1 Process found, but nothing found in the Event Log. Exiting Script.

    *2*) Changing the subject, I observed that the shadow copy is erased when it is older than 6 minutes and not 6 hours. I paste the lines from vsslog below:
    2/5/2019 3:59:57 PM -- Folder Exists, checking Time Stamp - 2/5/2019 3:52:38 PM
    2/5/2019 3:59:57 PM -- Difference is: 7
    2/5/2019 3:59:57 PM -- Shadow Folder is more than 6 hours - Removing Shadow Folder

    Report

Leave a comment

Because of spammers, I've changed the comments so they do not auto-show, but if you leave a comment, it should post within 24 hours.