{"id":20681343,"url":"https://github.com/d0whc3r/node-gdrive","last_synced_at":"2025-04-22T11:44:21.615Z","repository":{"id":34365799,"uuid":"173693430","full_name":"d0whc3r/node-gdrive","owner":"d0whc3r","description":"Google drive api for node made easy with typescript","archived":false,"fork":false,"pushed_at":"2025-04-14T21:31:19.000Z","size":1582,"stargazers_count":7,"open_issues_count":43,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-14T22:32:08.947Z","etag":null,"topics":["backup","compress","copy","drive","gdrive","google","google-drive","googleapi","node","upload"],"latest_commit_sha":null,"homepage":"https://hub.docker.com/r/d0whc3r/gdrive","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/d0whc3r.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-03-04T07:15:44.000Z","updated_at":"2024-10-28T00:35:26.000Z","dependencies_parsed_at":"2023-01-15T06:36:48.555Z","dependency_job_id":"e2efec39-8506-4a41-be38-be5b3bd9cba9","html_url":"https://github.com/d0whc3r/node-gdrive","commit_stats":{"total_commits":270,"total_committers":8,"mean_commits":33.75,"dds":0.5111111111111111,"last_synced_commit":"0601937cc3b5f4bb9b5260abf8a0ae6645e78870"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d0whc3r%2Fnode-gdrive","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d0whc3r%2Fnode-gdrive/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d0whc3r%2Fnode-gdrive/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d0whc3r%2Fnode-gdrive/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/d0whc3r","download_url":"https://codeload.github.com/d0whc3r/node-gdrive/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250237441,"owners_count":21397397,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backup","compress","copy","drive","gdrive","google","google-drive","googleapi","node","upload"],"created_at":"2024-11-16T22:10:34.160Z","updated_at":"2025-04-22T11:44:21.596Z","avatar_url":"https://github.com/d0whc3r.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# :floppy_disk: Node gdrive\n\nUtility to manipulate google drive using nodejs. It could upload content to google drive and it could be used as backup service.\n\n# :eyes: Project status\n\n[![pipeline status](https://gitlab.com/d0whc3r/node-gdrive/badges/master/pipeline.svg)](https://github.com/d0whc3r/node-gdrive)\n[![codecov](https://codecov.io/gh/d0whc3r/node-gdrive/branch/master/graph/badge.svg)](https://codecov.io/gh/d0whc3r/node-gdrive)\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/2612116bab5f493cada70bffc3cb6492)](https://www.codacy.com/app/d0whc3r/node-gdrive?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=d0whc3r/node-gdrive\u0026amp;utm_campaign=Badge_Grade)\n\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=d0whc3r_node-gdrive\u0026metric=alert_status)](https://sonarcloud.io/dashboard?id=d0whc3r_node-gdrive)\n[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=d0whc3r_node-gdrive\u0026metric=sqale_rating)](https://sonarcloud.io/dashboard?id=d0whc3r_node-gdrive)\n[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=d0whc3r_node-gdrive\u0026metric=security_rating)](https://sonarcloud.io/dashboard?id=d0whc3r_node-gdrive)\n[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=d0whc3r_node-gdrive\u0026metric=bugs)](https://sonarcloud.io/dashboard?id=d0whc3r_node-gdrive)\n[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=d0whc3r_node-gdrive\u0026metric=vulnerabilities)](https://sonarcloud.io/dashboard?id=d0whc3r_node-gdrive)\n\n![dependencies](https://img.shields.io/david/d0whc3r/node-gdrive.svg)\n[![npm version](https://img.shields.io/npm/v/@d0whc3r%2Fnode-gdrive.svg)](https://www.npmjs.com/package/@d0whc3r/node-gdrive)\n\n[![](https://img.shields.io/docker/cloud/build/d0whc3r/gdrive.svg)](https://hub.docker.com/r/d0whc3r/gdrive)\n[![](https://images.microbadger.com/badges/version/d0whc3r/gdrive.svg)](https://hub.docker.com/r/d0whc3r/gdrive)\n[![](https://images.microbadger.com/badges/image/d0whc3r/gdrive.svg)](https://hub.docker.com/r/d0whc3r/gdrive)\n\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fd0whc3r%2Fnode-gdrive.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fd0whc3r%2Fnode-gdrive?ref=badge_shield)\n\n## :key: Create credentials and token files\n\nTo get `credentials.json` file you need to visit:\n- [https://developers.google.com/drive/api/v3/quickstart/nodejs](https://developers.google.com/drive/api/v3/quickstart/nodejs)\n\nThen click `ENABLE THE DRIVE API` and click `DOWNLOAD CLIENT CONFIGURATION`\n\nThis will download **credentials.json** file, you can save it in *secrets* folder in the project.\nNow you need to generate **token.json** file, to do this you need to execute any command to access your google-drive, for example:\n\n### :boat: Using docker\n\nThen you could execute a simple command to generate token.json:\n\n\u003e Be careful to copy `credentials.json` into `$PWD/secrets` path\n\n```bash\ndocker run --rm -it -v $PWD/secrets:/app/secrets/ d0whc3r/gdrive -l\n```\n\n### :pencil: Using downloaded project\n\n\u003e First you need to download project from github using:\n\n```bash\ngit clone https://github.com/d0whc3r/node-gdrive.git\ncd node-gdrive\nyarn install\n```\n\nThen you could execute a simple command to generate token.json:\n\n```bash\nyarn cli -l\n```\n\n### :beginner: Next step\n\nUsing docker or project files the `-l` command is for listing existing files in google-drive\n\nIf *credentials.json* is present but *token.json* is missing this last file will be generated showing an url into terminal output, you need to enter that url and validate all needed permisions, then a token will be shown in your web browser, this token need to be pasted in terminal.\n\nBy default this software check for credentials (and token) file in folder `secrets` but it could be changed using environment variables:\n- **CREDENTIALS_FILE**: File with credentials (credentials.json)\n- **TOKEN_FILE**: File with token, generated using credentials (token.json)\n\n## :boat: Docker usage\n\nYou could use cli app in docker\n\n### :rowboat: Build docker image\n\n```bash\ndocker build -t gdrive .\n```\n\n### :checkered_flag: Run cli commands inside docker\n\n```bash\ndocker run --rm gdrive --help\n```\nTo make docker image work properly you need to indicate where credentials and token are located\n\n```bash\ndocker run --rm -v $PWD/secrets:/app/secrets:ro gdrive -l\n```\n\n## :checkered_flag: Cli help output\n\nUsing docker image from [hub.docker.com](https://hub.docker.com/r/d0whc3r/gdrive)\n\n```bash\ndocker run --rm d0whc3r/gdrive --help\n```\n\n```\nHelp for gdrive\n\n  Usage of npm gdrive in command line. \n\nOptions\n\n  -l, --list                                     List all files and folders                                                    \n  -b, --backup file*                             Backup files                                                                  \n  -z, --zip zipname.zip                          Zip backup files                                                              \n  -r, --replace                                  Replace files if already exists when backup upload                            \n  -c, --create                                   Create destination upload folder                                              \n  -f, --folder foldername                        Folder name to upload file/s                                                  \n  -d, --delete foldername=duration OR duration   Clean files older than duration in foldername                                 \n  -m, --mysql                                    Mysql backup using environment variables to connect mysql server              \n                                                 ($MYSQL_USER, $MYSQL_PASSWORD, $MYSQL_DATABASE, $MYSQL_HOST, $MYSQL_PORT)     \n  -h, --help                                     Print this usage guide.                                                       \n\nExamples\n\n  1. List files.                                                                      $ gdrive -l                                                   \n  2. Backup multiple files to \"backupFolder\" folder.                                  $ gdrive -b src/index.ts -b images/logo.png -f backupFolder   \n  3. Backup files using wildcard to \"backup\" folder.                                  $ gdrive -b src/* -b images/* -f backup                       \n  4. Backup files using wildcard and zip into \"zipped\" folder folder will be          $ gdrive -b src/* -b images/* -z -f zipped -c             \n  created if it doesn't exists.                                                                                                                     \n  5. Backup files using wildcard and zip using \"allfiles.zip\" as filename into        $ gdrive -b src/* -b images/* -z allfiles.zip -f zipped -c -r \n  \"zipped\" folder folder will be created if it doesn't exists and zipfile will be                                                                   \n  replaced if it exists                                                                                                                             \n  6. Delete files in \"uploads\" folder older than 2days and files in \"monthly\"         $ gdrive -d uploads=2d -d monthly=1M                          \n  folder older than 1month                                                                                                                          \n  7. Delete files in \"uploads\" folder older than 1minute                              $ gdrive -f uploads -d 1m                                     \n  8. Generate mysql dump file zip it and upload to \"mysql-backup\" folder              $ gdrive -f mysql-backup -m -z   \n```\n\n\n## License\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fd0whc3r%2Fnode-gdrive.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fd0whc3r%2Fnode-gdrive?ref=badge_large)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fd0whc3r%2Fnode-gdrive","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fd0whc3r%2Fnode-gdrive","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fd0whc3r%2Fnode-gdrive/lists"}