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

localbackup

v0.0.4

Published

Utility to make local backups easily and without the hassle.

Downloads

65

Readme

Local Backup 🦄

Utility to make local backups (and now remote) easily and without the hassle. If you like the project you can leave a star! ⭐️

Basic Usage

It's as simple as running the following command:

npx localbackup --source /path/to/source --destdir /path/to/backups-dest --keeplast 10

The above command requires node and npm to be installed. It also works without node and has binaries to run without node.

Installation options

With NodeJS (recommended)

You can run localbackup directly with no installation, just node and npm are required:

npx localbackup

Without NodeJS

You can download prebuilt binaries for the three major operating systems (windows, mac and linux) from the releases page.

Then you can just execute the binary from terminal, windows example:

localbackup.exe --source /path/to/source --destdir /path/to/backups-dest

CLI Options

To see the options available for your version of localbackup you can always run this command:

npx localbackup --help

Options:

| Option | Description | | --- | --- | | -s, --source | full path of the file or directory to be backed up | | -d, --destdir | full path of the destination directory where the backup file will be stored | | -t, --filetype | file type of the backup file (zip or tar) (default: "zip") | | -p, --prefix | prefix to be added to the backup file name (default: "backup") | | -k, --keeplast | number of backups to keep (olders with the same prefix will be deleted) | | -sp, --storageprovider | storage provider to use (local, s3) (default: "local", no config needed) | | -y, --yes | answer yes to all questions (default: false) | | -h, --help | display help for command |

Usage:

npx localbackup [options]

Keeplast option

The --keeplast option indicates how many backup copies to keep. When executing the command and after completing the backup, all files within the destination folder that match the prefix (--prefix option) and the extension (--filetype option) will be searched and only the specified amount will be kept (including the one generated in the current execution), the rest will be permanently deleted.

This option is especially useful when working with cron jobs and want to keep only a specific number of backups to save space or for whatever reason.

If no value is specified, the deletion process will be skipped.

Examples

Backup folder and keep only the last 10 backups on the destination directory:

npx localbackup --source /path/to/source --destdir /path/to/backups-dest --keeplast 10

Backup folder and keep only the last 10 backups using s3 as destination:

export LOCALBACKUP_S3_ENDPOINT="s3.us-west-002.backblazeb2.com"
export LOCALBACKUP_S3_BUCKET="mybucket"
export LOCALBACKUP_S3_ACCESS_KEY="myaccesskey"
export LOCALBACKUP_S3_SECRET_KEY="mysecretkey"

npx localbackup --source /path/to/source --destdir /path/to/backups-dest --keeplast 10 --storageprovider s3

Backup single file:

npx localbackup --source /path/to/file.png --destdir /path/to/backups-dest

Change destination file prefix:

npx localbackup --source /path/to/source --destdir /path/to/backups-dest --prefix mycustombackup

Run with no user confirmation (useful for cronjobs):

npx localbackup --source /path/to/source --destdir /path/to/backups-dest --keeplast 10 --yes

Store backups in S3 bucket

localbackup allows you to use an S3 bucket as a destination for your backups. To use this feature, you must first set up environment variables that tell localbackup which credentials to use to connect to S3:

  • LOCALBACKUP_S3_ENDPOINT: S3 endpoint (optional), useful for compatible providers, not necessary for native S3
  • LOCALBACKUP_S3_BUCKET: Bucket name (required)
  • LOCALBACKUP_S3_ACCESS_KEY: Access key (required)
  • LOCALBACKUP_S3_SECRET_KEY: Secret key (required)

After setting up the environment variables, you can continue using localbackup normally, and to activate S3, you just need to add the -sp (--storageprovider) option to the command:

npx localbackup --source /path/to/source --destdir /path/to/backups-dest --storageprovider s3

The above command creates backups and saves them to S3. All other options work the same way.

Usage with cron jobs

Cron jobs are scheduled tasks that run automatically at specified times or intervals on a Unix-based system.

You can easily use localbackup inside a cron job to periodically backup files and folders.

This is an example of cron expression that create backups of directory every day at 1:00 PM and only keep the last 10 backups:

0 13 * * * npx localbackup --source /path/to/source --destdir /path/to/backups-dest --keeplast 10 --yes
  • Read more about cron jobs: https://www.freecodecamp.org/news/cron-jobs-in-linux/
  • Easily create cron expressions: https://crontab.guru/