go-sftpsync is a simple and efficient tool to synchronize files between local and remote directories using SFTP. This tool allows you to upload or download files and supports flexible configurations for connecting to SFTP servers.
- Sync Local and Remote Directories: Easily synchronize files between your local system and an SFTP server.
- Multiple Profiles: Manage multiple SFTP configurations using profiles for seamless switching between environments.
- Flexible Operations: Perform both upload and download operations based on your needs.
- Configurable Authentication: Supports both password and private key-based authentication.
- Customizable Paths: Specify the local and remote base directories to fine-tune which files get synchronized.
- Error Handling: Handles errors such as permission denials and connection retries.
go-sftpsync sync [flags]-c, --config-file stringConfig file path to manage multiple profiles.-h, --helpShow help for thesynccommand.-H, --host stringSpecify the SFTP host to connect to.-l, --local-base-path stringSet the local base path for synchronization.-o, --operation stringDefine the operation to perform:uploadordownload.-p, --password stringSFTP password for authentication.-P, --port stringSpecify the SFTP port (default is 22).-k, --private-key stringPath to the private key for key-based authentication.-f, --profile stringProfile name from the configuration file.-r, --remote-base-path stringSet the remote base path for synchronization.-u, --user stringSFTP username for authentication.
To download files from a remote directory to your local machine:
go-sftpsync sync -o download -H sftp.example.com -u youruser -p yourpassword -l /local/dir -r /remote/dirTo upload files from a local directory to an SFTP server:
go-sftpsync sync -o upload -H sftp.example.com -u youruser -p yourpassword -l /local/dir -r /remote/dirYou can define multiple profiles in a YAML configuration file and switch between them using the --profile flag. This simplifies managing multiple SFTP servers or environments.
profiles:
profile1:
operation: upload
host: sftp.example.com
port: "22"
user: user1
password: pass1
private_key: /path/to/private/key1
local_base_path: /local/path1
remote_base_path: /remote/path1
profile2:
operation: download
host: sftp.example2.com
port: "22"
user: user2
password: pass2
private_key: /path/to/private/key2
local_base_path: /local/path2
remote_base_path: /remote/path2You can then specify the profile during synchronization:
go-sftpsync --config-file=$(pwd)/profiles.yaml --profile=backupfilesThis project is licensed under the MIT License.
© 2024 Thiago Zilli Sarmento. Made with ❤️ and Golang.