gosyncit

command module
v0.0.17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 27, 2023 License: MIT Imports: 1 Imported by: 0

README

MIT license Build Status

gosyncit

A project to explore directory mirror / sync in go, alongside a cobra/viper-based CLI. Since v0.0.13, this is extended by a platform-independent tool to mirror / sync files via SFTP. This can be useful for instance if there is no rsync available on the SFTP server.

installation

Assumes the go toolchain to be installed:

go install github.com/FObersteiner/gosyncit@latest

usage

local storage
mirror A → B

Write files to destination if source is newer or file size doesn't match, only keep files that exist in source (see flags).

>>> gosyncit mirror --help

Mirror the content of source directory to destination directory.
Files will only be copied if the source file is newer.
By default, anything that exists in the destination but not in the source will be deleted.

Usage:
  gosyncit mirror 'src' 'dst' [flags]

Aliases:
  mirror, mi

Flags:
  -n, --dryrun       show what will be done
  -x, --dirty        do not remove anything from dst that is not found in source
  -s, --skiphidden   skip hidden files
  -v, --verbose      verbose output to the command line
  -h, --help         help for mirror

Global Flags:
      --config string   config file (default is $HOME/.gosyncit.toml)
sync A ↔ B

Ensure source and destination have the same content, keep only the newest version of any file.

>>> gosyncit sync --help

Synchronize the content of source directory with destination directory.
Files will be copied if one is newer or doesn't exit in the destination.

Usage:
  gosyncit sync 'src' 'dst' [flags]

Aliases:
  sync, sy

Flags:
  -n, --dryrun       show what will be done
  -s, --skiphidden   skip hidden files
  -v, --verbose      verbose output to the command line
  -h, --help         help for sync

Global Flags:
      --config string   config file (default is $HOME/.gosyncit.toml)
local storage to SFTP and vice versa

The direction can either be "local --> remote" or "remote --> local". "local" in this context means local file system, remote means file system of the SFTP server.

>>> gosyncit sftpmirror --help

the direction can either be "local --> remote" or "remote --> local".
  "local" in this context means local file system, remote means file system of the sftp server.

Usage:
  gosyncit sftpmirror 'local-path' 'remote-path' 'remote-url' 'username' [flags]

Aliases:
  sftpmirror, smir

Flags:
  -p, --port int     ssh port number (default 22)
  -r, --reverse      reverse mirror: remote to local instead of local to remote
  -n, --dryrun       show what will be done
  -s, --skiphidden   skip hidden files
  -x, --dirty        do not remove anything from dst that is not found in source
  -v, --verbose      verbose output to the command line
  -h, --help         help for sftpmirror

Global Flags:
      --config string   config file (default is $HOME/.gosyncit.toml)

Notes

  • Directory tree traversal is always recursive. There is no option to just copy/mirror/sync the top-level directory
file comparison quirks
  • Test for equality is only done by comparing modification timestamp (mtime) and size (n bytes). Theoretically, if two files have the same name, mtime and size, they will be considered 'identical' although their content could be different. To prevent this incorrect result, a byte-wise comparison ('deep-equal') would be needed if the basic comparison says 'equal'
  • timestamp comparison granularity is microseconds at the moment (see lib/compare/compare.go, BasicUnequal). Nanosecond granularity was causing issues if a file was copied to a remote server. Windows only supports precision down to a period of 100 ns
  • sync, mirror: if two files with unequal size but the same name and path also have the same mtime in source and destination, then the content of the source will take prevalence (i.e. will copied to destination)
open issues
not planned
  • follow symlinks
  • inclusion / exclusion lists, regex patterns etc.

Documentation

Overview

Copyright © 2023 Florian Obersteiner <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Directories

Path Synopsis
lib

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL