escp (Enhanced SCP) is a tool designed to work like scp but with the added capability of automatically ignoring files or folders based on specified patterns (similar to .gitignore). It is especially useful for uploading files to remote servers like EC2, while excluding certain files or directories that you don't want to upload.
While working with scp to upload files to EC2, I wanted a way to automate the process and ignore files or folders of specific patterns (e.g., log files, temporary files, or large directories). With escp, you can define a .scpignore file, similar to .gitignore, to list patterns of files or directories to exclude during the scp upload.
- Pattern-based exclusion: Define file and directory patterns in a
.scpignorefile to automatically exclude them from being uploaded.
To build the binary for escp, follow these steps:
-
Clone the repository:
git clone https://github.com/Agent-Hellboy/escp.git cd escp -
Build the binary:
go build -o escp
-
(Optional) Move the binary to your
$PATHfor easier access:mv escp /usr/local/bin/
-
Create a
.scpignorefile in the root of your project (same directory where you're runningescp) and add the patterns you want to ignore. Example.scpignore:*.log # Ignore all log files temp/ # Ignore everything in the temp directory secret/*.key # Ignore all key files in the secret directory -
Use
escpto copy files just like you would withscp. The tool will automatically read the.scpignorefile and skip files that match the patterns:./escp source_directory/ user@ec2:/path/to/destination
-
escpwill print the list of files being copied and will exclude those specified in the.scpignorefile.
Let's say you have the following directory structure:
project/
├── .scpignore
├── build/
│ ├── artifact.log
│ ├── binary
├── secret/
│ └── api.key
└── src/
├── main.go
└── util.go
And the .scpignore file contains:
*.log
secret/
When you run escp:
./escp project/ user@ec2:/path/to/destinationThe following files will be uploaded:
project/src/main.goproject/src/util.go
The following files will be ignored:
project/build/artifact.logproject/secret/api.key
-
Performance Enhancements:
- Add support for parallel file uploads to speed up large directory transfers.
- Implement incremental uploads, so only files that have changed are copied.
-
Error Handling and Logging:
- Add a verbose mode (
-v) to log detailed information during file transfers. - Enhance error handling by retrying failed transfers and improving error messages.
- Add a verbose mode (
-
Cross-Platform Support:
- Extend support for Windows environments using WSL (Windows Subsystem for Linux) or native support.
-
Multiple Ignore Files:
- Support multiple ignore files such as
.scpignoreand.escpignore. Allow custom ignore files with a command-line argument.
- Support multiple ignore files such as
-
Pattern Matching Test Cases:
- Test common patterns (
*.log,subdir/,subdir/*). - Check that deeply nested directories are correctly ignored.
- Test common patterns (
-
Unit Tests:
- Write Go unit tests for key functions like
shouldIgnore,filterFiles, andparseDirectory.
- Write Go unit tests for key functions like
-
Integration Tests:
- Run integration tests to ensure
escpworks as expected across different directory structures and file patterns.
- Run integration tests to ensure
-
Use
.gitignoreTest Suite for Inspiration:- Git’s
.gitignoretest suite can serve as a great reference. Build a similar test suite to ensureescpreliably ignores files and directories based on the defined patterns.
- Git’s
I am 100% sure this broken , please test it and try to contribute if possible
This project is licensed under the MIT License.