# @ayoubamine/backsync

> Backup and sync your data with ease.

Latest version **1.3.0** (published 2021-09-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install @ayoubamine/backsync
pnpm add @ayoubamine/backsync
yarn add @ayoubamine/backsync
bun add @ayoubamine/backsync
```

Provides the command `backsync`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.0 |
| Published | 2021-09-15 |
| First published | 2021-09-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 19 |
| Unpacked size | 31.6 KB |
| Known vulnerabilities | 0 (+8 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 7 |
| Author | Ayoub AMINE |
| Maintainers | ayoubamine |
| Keywords | backup, sync, files, directories, mongodb, gdrive, dropbox |

## Links

- npm: https://www.npmjs.com/package/@ayoubamine/backsync
- Repository: https://github.com/ayoubamine/backsync
- Homepage: https://github.com/ayoubamine/backsync#readme
- Issues: https://github.com/ayoubamine/backsync/issues
- npm.io page: https://npm.io/package/@ayoubamine/backsync

## Dependencies (19)

- [chalk](https://npm.io/package/chalk.md) ^4.1.2
- [clear](https://npm.io/package/clear.md) ^0.1.0
- [figlet](https://npm.io/package/figlet.md) ^1.5.2
- [mysql2](https://npm.io/package/mysql2.md) ^2.3.0
- [nanoid](https://npm.io/package/nanoid.md) ^3.1.25
- [sqlite](https://npm.io/package/sqlite.md) ^4.0.23
- [aws-sdk](https://npm.io/package/aws-sdk.md) ^2.989.0
- [dropbox](https://npm.io/package/dropbox.md) ^10.9.0
- [mongodb](https://npm.io/package/mongodb.md) ^4.1.2
- [sqlite3](https://npm.io/package/sqlite3.md) ^5.0.2
- [archiver](https://npm.io/package/archiver.md) ^5.3.0
- [inquirer](https://npm.io/package/inquirer.md) ^8.1.3
- [commander](https://npm.io/package/commander.md) ^8.2.0
- [cronstrue](https://npm.io/package/cronstrue.md) ^1.117.0
- [node-cron](https://npm.io/package/node-cron.md) ^3.0.0
- [clean-deep](https://npm.io/package/clean-deep.md) ^3.4.0
- [cli-table3](https://npm.io/package/cli-table3.md) ^0.6.0
- [googleapis](https://npm.io/package/googleapis.md) ^86.1.0
- [inquirer-path](https://npm.io/package/inquirer-path.md) ^1.0.0-beta5

## Alternatives

- [angular-pipes](https://npm.io/package/angular-pipes.md) — 5.6K weekly downloads
- [@ng-web-apis/midi](https://npm.io/package/@ng-web-apis/midi.md) — 2.6K weekly downloads
- [happn-3](https://npm.io/package/happn-3.md) — 1.6K weekly downloads
- [@opensip-cli/lang-go](https://npm.io/package/@opensip-cli/lang-go.md) — 1.2K weekly downloads
- [mongoose-typescript](https://npm.io/package/mongoose-typescript.md) — 85 weekly downloads

## Recent versions

- 1.3.0 (latest) — 2021-09-15
- 1.2.2 — 2021-09-15
- 1.2.1 — 2021-09-15

## README

# BackSync

> Backup and sync your data with ease.

Supported backup:

- Local
- MongoDB
- MySQL

Supported sync:

- Local
- Google Drive
- Dropbox
- AWS S3

## Install

```bash
npm i -g @ayoubamine/backsync
```

## Usage

Generate config file `backsync.json`:

```bash
backsync init
```

Add backup source:

```bash
backsync add backup
```

Add sync source:

```bash
backsync add sync
```

Update default settings:

```bash
backsync settings
```

Run the backup and sync manually:

```bash
backsync run
```

Schedule the backup and sync in the [background](#process-management):

```bash
backsync schedule
```

Show the sync history:

```bash
backsync status
```

## Process Management

Install PM2 to run the process in the background:

```bash
npm i -g pm2
```

Create `ecosystem.config.js` file in the same directory that `backsync.json` exists and add the following content:

```js
module.exports = {
  apps: [
    {
      name: 'backsync',
      script: 'backsync',
      args: 'schedule',
    },
  ],
};
```

Then to start:

```bash
pm2 start ecosystem.config.js
```

Display the logs:

```bash
pm2 logs backsync
```

To stop and delete:

```bash
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](https://cloud.google.com/docs/authentication/production#create_service_account)

#### Step 2: Create backup folder

1. Go to <https://drive.google.com>.
2. Create new folder.
3. Right-click on the folder, select Share, add the service account email with the Editor permission and click Done.
4. 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

1. Go to <https://dropbox.com/developers/apps/create>.
2. Choose Scoped access on the first step.
3. Choose App folder on the second.
4. Give your app a name. That name will become a folder in your Dropbox account.
5. Click Create app.

#### Step 2: Generate access token

1. Go to Permissions tab and enable `files.content.write` scope.
1. Go to Settings tab, scroll down to OAuth 2 block, select 'No expiration' and click Generate.

### AWS S3

#### Step 1: AWS credentials

1. Go to <https://aws.amazon.com>.
2. Navigate to IAM > Users and click 'Add users'.
3. 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

1. Go to <https://s3.console.aws.amazon.com>.
2. 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](#google-drive) | `string` | Yes      |
| [folderId](#google-drive)    | `string` | Yes      |

#### Dropbox

| Name              | Type     | Required |
| ----------------- | -------- | -------- |
| [token](#dropbox) | `string` | Yes      |

#### AWS S3

| Name                       | Type     | Required |
| -------------------------- | -------- | -------- |
| [accessKeyId](#aws-s3)     | `string` | Yes      |
| [secretAccessKey](#aws-s3) | `string` | Yes      |
| [bucketName](#aws-s3)      | `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](https://github.com/ayoubamine/backsync/issues).
If you fixed a bug or implemented a new feature, please send a [pull request](https://github.com/ayoubamine/backsync/pulls).

## Changelog

[CHANGELOG](./CHANGELOG.md)

## License

[MIT License](./LICENSE.md)

---
_Source: https://npm.io/package/@ayoubamine/backsync · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
