# backup-folder

> Backup a big local folder to google cloud storage

Latest version **1.2.0** (published 2022-02-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install backup-folder
pnpm add backup-folder
yarn add backup-folder
bun add backup-folder
```

Provides the command `backup-folder`.

## 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.2.0 |
| Published | 2022-02-05 |
| First published | 2021-05-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 11.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Hitesh Khandelwal |
| Maintainers | hkk12369 |
| Keywords | backup, sync, backup-folder, sync-folder, rsync, google-cloud-storage, gsutil, gcloud, gcs |

## Links

- npm: https://www.npmjs.com/package/backup-folder
- Repository: https://github.com/hkk12369/backup-folder
- Homepage: https://github.com/hkk12369/backup-folder#readme
- Issues: https://github.com/hkk12369/backup-folder/issues
- npm.io page: https://npm.io/package/backup-folder

## Dependencies (4)

- [chalk](https://npm.io/package/chalk.md) ^4.1.1
- [commander](https://npm.io/package/commander.md) ^7.2.0
- [async-parallel-queue](https://npm.io/package/async-parallel-queue.md) ^1.0.3
- [@google-cloud/storage](https://npm.io/package/@google-cloud/storage.md) ^5.8.5

## Alternatives

- [localforage](https://npm.io/package/localforage.md) — 6.2M weekly downloads
- [localforage-observable](https://npm.io/package/localforage-observable.md) — 30.8K weekly downloads
- [@y/y](https://npm.io/package/@y/y.md) — 30.1K weekly downloads
- [@metaobjectsdev/render](https://npm.io/package/@metaobjectsdev/render.md) — 3.5K weekly downloads
- [@ledgerhq/coin-algorand](https://npm.io/package/@ledgerhq/coin-algorand.md) — 1.1K weekly downloads

## Recent versions

- 1.2.0 (latest) — 2022-02-05
- 1.1.4 — 2021-05-15
- 1.1.3 — 2021-05-14
- 1.1.2 — 2021-05-14
- 1.1.1 — 2021-05-14
- 1.1.0 — 2021-05-14
- 1.0.4 — 2021-05-13
- 1.0.3 — 2021-05-13
- 1.0.2 — 2021-05-13
- 1.0.1 — 2021-05-13
- 1.0.0 — 2021-05-13

## README

## backup-folder
Backup a big folder to google cloud storage.

This script will backup your local folder to google cloud storage, it will only upload files that have changed between successive runs and will never delete any files (even if they are deleted from local folder).

GCS credentials are required for `backup-folder` to run, see [Authentication](#authentication) for details.

## Install
```sh
npm install -g backup-folder
# OR
yarn global add backup-folder
```

## How To Use

#### Options
```
backup-folder -h

Usage: index [options] <source> <destination>

Backup a local folder to google cloud storage

Arguments:
  source         local folder to backup
  destination    gcs address where backup should be uploaded (must start with gs://) (eg. gs://my-bucket/my-folder/)

Options:
  -V, --version  output the version number
  -p, --print    only print files to be uploaded, do not actually upload (default: false)
  -q, --quiet    quiet mode, don't print the files to be uploaded to stdout (default: false)
  -h, --help     display help for command
```

#### Example
```sh
# Backup ./src/images to inside images folder of google cloud storage bucket my-bucket
backup-folder ./src/images/ gs://my-bucket/images/
```

## Authentication
You can authenticate to google cloud storage either via `gcloud` command or using a service account.

#### Via gcloud
```sh
gcloud auth application-default login
```

#### Via service account
```sh
GOOGLE_APPLICATION_CREDENTIALS=<service account key.json> backup-folder <source> <destination>
# OR
export GOOGLE_APPLICATION_CREDENTIALS=<service account key.json>
backup-folder <source> <destination>
```

## How it works?
`backup-folder` will create a file named `.backup-folder.json` inside the local folder. This metadata file contains the timestamp when the folder was backed up. Running `backup-folder` again will read the last timestamp from this file and will only upload files which were modified after the last timestamp.

## Why not use gsutil rsync or cp?
* `rsync` command queries all the files in the destination bucket, which will create a lot of class A api requests (not free) and will cost you a lot if only small number of files are changing.
* `cp` will copy the whole folder which will again use a lot of bandwidth and going to cost a lot more.

Use `backup-folder` when you want to backup a folder which a large number of files, but only small number of files are added / changed per day.

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