This is a miniature CLI for syncing a folder with S3. This could probably be expanded into a proper CLI/Bash script eventually. This was created as a client request but may be useful to some.
npm start
Or, to force an update of a folder:
npm run force-sync
If you want some verbose debug logging:
npm start -- --debug
npm run force-sync -- --debug
You set up your AWS Credentials and an S3 bucket in a .env
file. Next, you run npm start
and pick a directory to sync. The tool will check that directory for a few things:
- If an
.s3backup
file exists, check the timestamp inside. The timestamp represents the last sync date. - Check the entire directory tree for valid files.
- Check each file to see if it has been create since the last backup timestamp, if there is one.
- If it has, add it to the stack for syncing.
- Sync all the required files and upload to the S3 bucket at a relative filepath (i.e, If you synced the
test
directory, the files would upload totest/**
inside the bucket.)
This is super un-intuitive but if you enter the directory that you wish to sync in your Terminal and then run the script directly using Node, i.e, node ../../sync-s3
, it will check the current directory to see if a .s3backup
file exists. If it does, it auto picks that directory as the one to sync.
- Allow for the syncing to happen based on last modified instead of birthtime.
- Improve file selection process.
- Change to a bash/bin script to allow it to be installed globally and used inside of any folder.
- Update to an Electron application/service.
- Allow files to be ignored.
- Allow extensions to be ignored.
- Create a more intuitive user experience.