Skip to content

.NET Core Workers as Directory Synchronization Services

License

Notifications You must be signed in to change notification settings

microcompiler/bytesync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

.NET Core Workers as Directory Synchronization Services

ByteSync directory synchronization worker service is based on source code of BlinkSync command line (http://blinksync.sourceforge.net).

Configuration

ByteSync reads from Microsoft.Extensions.Configuration, .NET Core's appsettings.json file. Configuration is read from the SyncService section.

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
  "SyncService": {
    "Interval": 10,
    "DirSrc": "c:\\SourceFolder",
    "DirDest": "c:\\DestinationFolder",
    "ExcludeHidden": true,
    "DeleteFromDest": true,
    "ExcludeFiles": [],
    "ExcludeDirs": [],
    "IncludeFiles": [],
    "IncludeDirs": [],
    "DeleteExcludeFiles": [],
    "DeleteExcludeDirs": []
  }
}

Filter options

There are many other filter options for more control if needed.

  • DeleteFromDest: Delete files and directories in destination which do not appear in source
  • DeleteExcludeFiles: Exclude files from deletion that match any of the filespecs
  • DeleteExcludeDirs: Exclude directories from deletion that match any of the
  • ExcludeHidden: Exclude hidden files and directory from source
  • ExcludeFiles: Exclude files from source that match any of the filespecs
  • ExcludeDirs: Exclude directories from source that match any of the filespecs
  • IncludeFiles: Only include files from source that match one of the filespecs
  • IncludeDirs: Only include directories from source that match one of the filespecs

Note: IncludeFiles and ExcludeFiles or IncludeDirs and ExcludeDirs may not be combined in the same filter.

Wildcards matching in paths can be used as filters. You can use '?' to match any single character and '*' to match zero or more of any characters.

{
  "SyncService": {
    "IncludeFiles": ["foo.*", "ba?.txt"],
  }
}

DeleteExcludeFiles and DeleteExcludeDirs exclude-from-deletion options require deletion DeleteFromDest enabled to be affective.

{
  "SyncService": {
    "DeleteFromDest": true,
    "DeleteExcludeFiles": ["foo.txt", "bar.txt", "foo\foo1.txt", "foo\foo2.txt"],
    "DeleteExcludeDirs": ["bin", "obj"]
  }
}

IncludeFiles and ExcludeDirs files options may be combined.

{
  "SyncService": {
    "ExcludeFiles": ["foo.txt", "bar.txt", "foo\foo1.txt", "foo\foo2.txt"],
    "ExcludeDirs": ["bin", "obj"]
  }
}

ExcludeFiles and ExcludeDirs directories options may be combined.

{
  "SyncService": {
    "ExcludeFiles": ["foo.txt", "bar.txt", "foo\foo1.txt", "foo\foo2.txt"],
    "ExcludeDirs": ["bin", "obj"],
  }
}

Level overrides

The default Logging configuration property can be set to Trace displaying all file copy commands. This is useful for validating include and exclude filters.

"Logging": {
  "LogLevel": {
    "Default": "Trace",
    "Microsoft": "Warning",
    "Microsoft.Hosting.Lifetime": "Information"
  }
}

Environment variables

You can add or override ByteSync configuration through the environment. For example, to set the sync interval, directory source and destination using the Windows command prompt:

set SYNCSERVICE__INTERVAL=30
set SYNCSERVICE__DIRSRC=c:\SourceFolder
set SYNCSERVICE__DIRDEST=c:\DestinationFolder

Command line

You can add or override ByteSync configuration through the command. For example, to set the sync interval, directory source and destination using the Windows command prompt:

byteSync.exe --SyncService:Interval=30 --SyncService:DirSrc="c:\SourceFolder" --SyncService:DirDest="c:\DestinationFolder"

Run as a Windows Service

Register ByteSync as a Windows Service using the Windows administrator command prompt:

sc create ByteSync displayname="Bytewize ByteSync" description="Directory synchronization worker service" binpath="<path>"

Running ByteSync as a windows service will output messages to the windows event log.

Build your own version

If you would like to modify the source code. Run the following Windows command according to your target platform.

Windows

dotnet publish --configuration Release --runtime win-x64 --output "<path>"

Linux (portable)

dotnet publish --configuration Release --runtime linux-x64 --output "<path>"

MacOS (OS X)

dotnet publish --configuration Release --runtime osx-x64 --output "<path>"

About

.NET Core Workers as Directory Synchronization Services

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages