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

dat-backup

v2.2.2

Published

Create copy of an archive to local folder.

Downloads

11

Readme

dat-backup

Backup a dat to local storage. Useful for:

  • Storing full history
  • Creating local backups of data (good for offline backups!)
  • More efficient storage (all content, latest and historic, is stored as a single content.data file)

Usage

A dat backup is good for situations where an archive is only storing the latest content but you want to keep historic version of content around locally, either temporarily or permanently.

var createBackup = require('dat-backup')

var archive = hyperdrive('/dir', {latest: true}) // some existing archive or dat-node instance

// default dir is ~/.dat/backups/<discovery-key>
var backup = createBackup(archive, {dir: '/big-hd/' + archive.discoveryKey.toString('hex')})

backup.ready(function (err) {
  if (err) throw err

  // backup archive at current version
  backup.add(function () {
  	console.log('archive backed up at version: ', archive.version)
  })

  // List all file versions available in archive backup
  backup.list(function (err, files) {
    if (err) throw err
    console.log(files)
  })
})

API

var backup = createBackup(source, [opts])

source is either a hyperdrive archive or dat-node instanace, dat.

Options are:

  • opts.dir: where to store backups, defaults to ~/.dat/backup/discKey.slice(0, 2), discKey.slice(2)

backup.ready()

Initalize the backup and make sure it is ready for adding, etc. This is often called automatically but for sync commands you may need to call it first, e.g. backup.list().

backup.add([opts], cb)

Create a new backup of the archive at current version. Will backup all content available in the current archive, but not any remote archives. callback will be called when finished, unless live.

Options are:

  • opts.live: Do a live backup, backing up content as it is updated. Will not callback.

backup.remove(start, [end], cb)

Remove archive version(s) from local backup.

Start and end have the following properties: {version: 0}. end.version defaults to start.version + 1.

You can also pass content block numbers directly (equivilant to archive.content.clear(start, end, cb)).

var stream = backup.list([opts], [cb])

List all data available in backup. Streams a list of files from archive.history() if they are backed up. opts are passed to archive.history.

If cb is provided, stream will collect the list and callback with (err, list).

backup.serve()

Serve data from a backup. This will allow users to download any data that is backed up.

License

MIT