Migrating from User to Service install on Windows


#1

Thanks to @martijnsmith for giving me the boost needed to “how-to” this!

If want to run Duplicati as a Windows service instead of under a specific user account OR maybe you find that you keep getting errors such as the following, it could be that you’re running Duplicati under a user install for a non-administrator user.

System.UnauthorizedAccessException: Access to the path '<path>' is denied.


Firstly, congratulations on not doing everyday work as an administrator! :slight_smile:


Secondly, disclaimers - running Duplicati under an elevated account (such as “Run as administrator” or as a system account service) gives it access to parts of the system most users can’t normally get to - including other user’s folders!

This means that anybody with access to the backup could be able to see AND RESTORE folder & file listings of other users. If that’s not an issue for you, then great - forge ahead!


Thirdly, you can likely resolve this issue in a few different ways, including:

  1. Run Duplicati as a service (the official way)
  2. Install and run Duplicati under an administrator account
  3. Update the Duplicati.GUI.TrayIcon.exe shortcut in your Startup folder to “Run this program as an administrator” (under the Compatibility tab of Properties)

Here we’re going to go over method #1.

  1. Stop the tray icon if you currently have it running
  2. Move the following from the “Src:” folder to the “Dst:” folder as shown bellow (use the “Prt:” folder if currently running in --portable-mode). Note that you may be prompted to give yourself access to the second folder:
    Src: C:\Users\ [your user name]\AppData\Roaming\Duplicati (Alternatively replace Roaming with Local.)
    Dst: C:\Windows\System32\config\systemprofile\AppData\Local\Duplicati
    (Prt: C:\Program Files\Duplicati 2\Data)
  3. Open a command prompt as an administrator (right click and select “Run as administrator”) and run Duplicati.WindowService.exe install in your Duplicati install folder (likely "C:\Program Files\Duplicati 2\Duplicati.WindowsService.exe" install)
  4. If you get the “Installation has completed” message, you can start the service with sc start Duplicati (or use a Windows Service GUI, your choice)
    But if you get an error such as the following then you probably didn’t open your command prompt as an authorized administrator, try again
    System.UnauthorizedAccessException: Access to the path 'C:\Program Files\Duplicati 2\Duplicati.WindowsService.InstallState' is denied.
  5. Once the service has been started go ahead and close the command prompt window (we’re done with it now)
  6. Open a browser window and go to http://localhost:8200 to make sure the service is working and found your existing settings (if that fails but http://localhost:8300 works, then you may have forgotten to stop the tray icon)
  7. The Tray icon is no longer needed so you can remove Duplicati from your Startup programs. However, if you like having the icon around then be sure to update the properties of any shortcuts to it (such as in the Startup folder) to include --no-hosted-server parameter as part of the Target field (this tells the Tray Icon to connect to the service instead of starting it’s own instance).

There you’re done! Duplicati should now run when the machine starts up whether or not a user is actually logged on.

A few final notes:
An issue was found with the service based Duplicati with Minio:
https://forum.duplicati.com/t/windows-service-minio-with-ssl-error/52/4?source_topic_id=660

Also, to REMOVE the Duplicati service (not just turn it off) you run Duplicati.WindowsServce.exe uninstall in your Duplicati install folder (so most likely something like "C:\Program Files\Duplicati 2\Duplicati.WindowsService.exe" uninstall.

If you experience errors like this one: Found 240 remote files that are not recorded in local storage, please run repair it is likely that your backup databases are not moved properly. To fix this go to the “Database …” menu under Advanced settings per backup job. There you will find an option to change the “Local database path” to your new Duplicati folder, the Dst-folder from step 2. Be careful if you have already moved the backup database files, so that you do not overwrite the proper ones.


Running as service, VSS not working
Taking a long time for 400GB
Changed from app to service: backup no longer found
Found 240 remote files that are not recorded in local storage, please run repair
Locked file, errors on outlook.pst
Scheduled Backup Does Not Run Without a User Logged On in Windows
Should 2.0.2.19 be promoted to the experimental channel?
Duplicati sqlite database doesn't seem to change after running backups (SOLVED)
Odd issue after installing as service and Duplicati.GUI.TrayIcon.exe
#2

See also this video (which is about installing rather than migrating):


#4

This is double, isn’t it?

I was going to ask: what exactly does --no-hosted-server do, but diligent a user that I am I first tried to find the answer myself and found it here:

--no-hosted-server to instructs Duplicati.GUI.TrayIcon.exe that it should not start the server itself, but connect to an already running instance.

In any case, your instructions worked perfectly for me. Thanks for putting them together. Probably saved me tons of time!

The only two points where I had to think twice was in step 2 where I initially wondered: “move what from src to dst?” And the other one was in step 7 where I wondered whether the attribute should be inside or outside the "", but I tried outside and it seems to work fine. :smile:


#5

Glad it worked for you!

And thanks for the tips - I’ve removed the duplicate step and tried to add some clarification to steps 2 and 3.

I have a feeling step 2 may get a little more complicated as I think there might be yet another potential location where the files could be, but I haven’t confirmed it yet (it might only be used in the latest canary).


#6

Is it normal that duplicati still creates .sqlite and .backup files in C:\Users\Username\AppData\Roaming\Duplicati even when I switched to service? Cause that is what I’m seeing right now.


#7

I haven’t checked that yet but I suspect it might be “normal” if not “desired”.

If you look at “Advanced options” on the “Commandline…” page does your dbpath setting show the tray based or service based location?


#8

Well spotted! It’s still the old path there. I suppose changing that path should be step 3 of the tutorial?


Found 240 remote files that are not recorded in local storage, please run repair
#9

Erm, well - I tried that but in my testing it didn’t “take”. For what I was doing it didn’t cause me any issues so just ignored it.

Here’s what was said about it in a few other topics…


#10

Okay, I see. I guess this one is quite relevant:

Which explains why

But, in if the database path stays the same after moving to duplicati as a service, why are you telling people to move the database?


#11

Good question - I put it in there because that’s where the database landed for me on a straight up service install, so rather than having a half-here-half-there setup I was hope to replicate what would have happened if they installed as a service from the start.

Secondarily, leaving the dbpath under a particular user’s account MIGHT end up running into permissions issues depending what credentials the service ends up running under.

But it is perfectly valid to leave the “Duplicati” folder where it is and add the appropriate parameter (I think there is one but I forget what it is) to the service startup so that it knows where to find the dbconfig.json and .sqlite files.


#12

My first install I did a normal install and later converted it to a service (running as SYSTEM). I had to move the .sqlite database files manually from under my user profile AppData directory to C:\Windows\System32\config\systemprofile\AppData\Local\Duplicati. Starting up without moving the config database acted like a clean install with zero knowledge of my existing settings or backup jobs.

Since then I’ve just been installing as a service initially without performing a normal install first.

I personally would prefer Duplicati to use c:\ProgramData\Duplicati when running as a service instead of …systemprofile\AppData. It seems a little cleaner in my mind and more in line with what I see most applications doing, but it doesn’t really matter. I could always move it if it really bugged me :slight_smile:


#13

I haven’t tested this yet but I believe if you add --protable-mode to the service startup parameters it will indeed use the folder you mentioned.


#14

--portable-mode stores all settings, backup configurations and local databases in a folder Data, located under the program folder.
If Duplicati is installed in C:\Program Files\Duplicati 2, --portable-mode will store everything in C:\Program Files\Duplicati 2\Data.

There’s a discussion about something similar here:


#15

You can set the environment variable DUPLICATI_HOME=C:\ProgramData\Duplicati and it will stop using %LOCALAPPDATA%Duplicati.


Duplicati sqlite database doesn't seem to change after running backups (SOLVED)
#16

Thanks for a great migration guide. Unfortunately I’m stuck with the same error as @tophee is describing.

Is there a way to migrate my backup-db to the “systemprofile”-folder, so that I don’t have to start my backup over again?


#17

Sure, but I’m not sure which error (“remote files” or “missing database”) you mean when you say you have the same error as tophee.


#18

Sorry for not being more precise.

I get the “Found xx remote files that are not recorded, please run repair” error, because the backup-job database is not moved. So instead of reading the sqlite file per backup-job from “systemprofile”-folder, it continues to read from my local user folder instead. (And when I moved the sqlite-files, it recreates empty ones.)

So my question is what steps are necessary to migrate the backup-sqlite files? :slight_smile:

Thanks!


#19

Got it!

You options at this point include:

  1. Run the repair which will rebuild the database based on what’s in those “xx remote files” (though this can take a while depending on your backup size)
  2. Point your service job to the existing database location (not recommended as it could be lead to confusion as to what’s stored where)
  3. Move (or copy) the existing database to the new location and point the service job to it
  4. Move (or copy) the existing database to the new location and rename it to match what the service job is already looking for

For 2-3 you’d want to use the job “Database …” menu. In there you can put the actual path to your database in the the “Local database path” field.

Most likely, the folder you want the database to live in will be:

  • C:\Windows\System32\config\systemprofile\AppData\Local\Duplicati (unless you’re using the portable mode parameter)

#20

Thanks a bunch! The “Database…” menu was exactly what I was missing. It also allowed me to move the database.

So maybe I could suggest an update in the migration guide, to move all the backup database-files with the “Move existing database” button? It did at least do the trick for me.

Thank you for your help! :smile:


#21

Good idea! I went ahead and made the first post a Wiki so feel free to update it based on your own recent experience! :smiley: