@ayoubamine/backsync
v1.3.0
Published
Backup and sync your data with ease.
Downloads
10
Maintainers
Readme
BackSync
Backup and sync your data with ease.
Supported backup:
- Local
- MongoDB
- MySQL
Supported sync:
- Local
- Google Drive
- Dropbox
- AWS S3
Install
npm i -g @ayoubamine/backsync
Usage
Generate config file backsync.json
:
backsync init
Add backup source:
backsync add backup
Add sync source:
backsync add sync
Update default settings:
backsync settings
Run the backup and sync manually:
backsync run
Schedule the backup and sync in the background:
backsync schedule
Show the sync history:
backsync status
Process Management
Install PM2 to run the process in the background:
npm i -g pm2
Create ecosystem.config.js
file in the same directory that backsync.json
exists and add the following content:
module.exports = {
apps: [
{
name: 'backsync',
script: 'backsync',
args: 'schedule',
},
],
};
Then to start:
pm2 start ecosystem.config.js
Display the logs:
pm2 logs backsync
To stop and delete:
pm2 delete backsync
Auth
Google Drive
Step 1: Create service account
Follow these steps to create a service account and download your credentials.json
file:
Create service account
Step 2: Create backup folder
- Go to https://drive.google.com.
- Create new folder.
- Right-click on the folder, select Share, add the service account email with the Editor permission and click Done.
- Browse to the new folder and copy the folder id from the url. 'https://drive.google.com/drive/u/0/folders/FOLDER_ID'
Dropbox
Step 1: Create an app in your Dropbox account
- Go to https://dropbox.com/developers/apps/create.
- Choose Scoped access on the first step.
- Choose App folder on the second.
- Give your app a name. That name will become a folder in your Dropbox account.
- Click Create app.
Step 2: Generate access token
- Go to Permissions tab and enable
files.content.write
scope. - Go to Settings tab, scroll down to OAuth 2 block, select 'No expiration' and click Generate.
AWS S3
Step 1: AWS credentials
- Go to https://aws.amazon.com.
- Navigate to IAM > Users and click 'Add users'.
- Fill the username, enable 'Access key - Programmatic access', click 'Next: Permissions', select 'Attach existing policies directly', enable the AmazonS3FullAccess permission and click 'Next: Tags' > 'Next: Review'.
Step 2: Create an S3 bucket
- Go to https://s3.console.aws.amazon.com.
- Click 'Create bucket', fill the bucket name and click 'Create bucket'.
API
Info
| Name | Type | Required |
| ----------- | -------- | -------- |
| name | string
| Yes |
| description | string
| No |
Backup
Local
Params
| Name | Type | Required |
| ---- | -------- | -------- |
| path | string
| Yes |
Settings
| Name | Type | Required |
| -------- | -------- | --------------------------- |
| filename | string
| No, Default: Original name. |
MongoDB
Params
| Name | Type | Required |
| -------- | -------- | ---------------------------------------- |
| uri | string
| No, Default: mongodb://localhost:27017
|
| database | string
| Yes |
Settings
| Name | Type | Required |
| -------- | -------- | --------------------------- |
| filename | string
| No, Default: Database name. |
MySQL
Params
| Name | Type | Required |
| -------- | -------- | ----------------------- |
| host | string
| No, Default: hostname
|
| port | number
| No, Default: 3306
|
| user | string
| No, Default: root
|
| password | string
| No |
| database | string
| Yes |
Settings
| Name | Type | Required |
| -------- | -------- | --------------------------- |
| filename | string
| No, Default: Database name. |
Sync
Local
| Name | Type | Required |
| ---- | -------- | -------- |
| path | string
| Yes |
GDrive
| Name | Type | Required |
| ---------------------------- | -------- | -------- |
| credentials | string
| Yes |
| folderId | string
| Yes |
Dropbox
| Name | Type | Required |
| ----------------- | -------- | -------- |
| token | string
| Yes |
AWS S3
| Name | Type | Required |
| -------------------------- | -------- | -------- |
| accessKeyId | string
| Yes |
| secretAccessKey | string
| Yes |
| bucketName | string
| Yes |
Settings
| Name | Type | Required |
| -------- | -------- | ------------------------ |
| cron | string
| No, Default: 0 0 * * *
|
| prefix | string
| No |
| filename | string
| No |
Contributions
Feel free to contribute to this project.
If you find a bug or want a feature, but don't know how to fix/implement it, please fill an issue. If you fixed a bug or implemented a new feature, please send a pull request.