npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gcloud-backup

v1.1.1

Published

A single-purpose Node.js CLI to backup any local folder to any Google Cloud Storage bucket.

Downloads

7

Readme

gcloud-backup

A single-purpose Node.js CLI to backup any local folder to any Google Cloud Storage bucket, regardless of size.

Installation

npm install -g gcloud-backup or npm install gcloud-backup if you want to use this programatically.

Testing

Are you kidding? This is not for mission-critical stuff. It's ~130 lines of JavaScript. And you have to test these things manually anyway... so I'm not complicating this.

General Usage

The point of gbackup is to back up one folder at a time to Google Cloud Storage. I'm using it for long-term, cold backup, but you could use it for anything. It also tracks rough upload progress for large file counts.

The biggest issue that this solves is that when you're uploading tons of data over hours and hours, you'll occasionally have connectivity problems, or your machine will go to sleep, and you want to be able to resume the upload process without duplicating your files. gbackup scans your folder and scans your bucket for matching files. It counts out how many files have been uploaded and how many need to be uploaded and goes to work on the need-to-be-uploaded files.

Once a file has been uploaded, gbackup adds an extended file attribute—-gbackup-md5Hash--to each uploaded filesystem. This md5Hash matches the hash of the gzipped file on Google Cloud Storage. So once gbackup is done uploading new files, it will start overwriting changed files. If you don't want it to do that, remove lines 141 through 144 of index.js. Or don't change files in your backup folder. Whatever you like... I don't care.

gbackup respects folder structure, but won't waste time with absolute paths. For example, if your folder is /Users/myUser/video, and your ~/video folder has a bunch of sub-folders, gbackup will place each file within it's correct sub-folder, and the sub-folders will all live within gs://my-terrible-bucket/video/.

My idea was to put a single folder of massive video files on into a bucket while maintaining a reasonable folder structure. The code isn't that fancy, so hack it to your needs and let me know how it goes.

CLI Use

I'm currently backing up a bunch of videos from my desktop to a storage bucket.

Details:

  • Folder: /Users/quiver/Desktop/video
  • Bucket: coldline.chrisesplin.com
  • Service Account: ~/.gcloud/chris-esplin-service-account.json
  • Project Id: chrisesplin

How the CLI call looks

gbackup /Users/quiver/Desktop/video -b coldline.chrisesplin.com -s ~/.gcloud/chris-esplin-service-account.json -p chrisesplin -e SkipThisFolderName

You have to pass in all of those flags to make it work. Also, you can pass in a storage class like this: -s NEARLINE or -s REGIONAL

gbackup defaults to -s COLDLINE, which is crazy cheap and appropriate for the family videos that I don't expect to need unless my house burns down or my kids steal and lose my external hard drives.

Programatic Node.js Use

I haven't tested this at all, but this module does expose a start() function. It uses start() internally, so it should work fine as a local module. If not, send me an issue or a pull request and I'll fix it.

Here's how start() looks.

var gbackup = require('gcloud-backup');
var path = '/Users/myUser/Desktop/someFolder';
var bucketName = 'my-terrible-bucket';
var projectId = 'some-project-id-123456';
var serviceAccount = '/Users/myUser/.super-secret-folder/service-account.json';
var excludedRegex = 'MassiveFilesToIgnore';
var metadata = {
  storageClass: 'NEARLINE'
};
gbackup.start(path, bucketName, projectId, serviceAccount, excludedRegex, metadata);

The only tricky thing to note here is that the metadata should only include metadata that you want to set for all files. Most files will set their own metadata just fine, but if you want to get fancy and maybe even serve these files publicly, that's entirely up to you. It's outside of my one-day budget to create this tool, so I'm not testing it unless this thing gets popular and people bug me about it.