Welcome
Awesome Dat
Dat Applications
datproject/dat
datproject/dat-desktop
Community Applications
codeforscience/sciencefair
mafintosh/hyperirc
jondashkyle/soundcloud-archiver
mafintosh/hypervision
joehand/hypertweet
beakerbrowser/dat-photos-app
High-Level APIs
datproject/dat-node
datproject/dat-js
beakerbrowser/pauls-dat-api
beakerbrowser/node-dat-archive
Hosting & Dat Management
mafintosh/hypercore-archiver
datprotocol/hypercloud
beakerbrowser/hashbase
joehand/dat-now
mafintosh/hypercore-archiver-bot
joehand/hypercore-archiver-ws
datproject/dat-registry-api
datproject/dat-registry-client
Managing & Aggregating Dats
datproject/multidat
datproject/multidrive
jayrbolton/dat-pki
beakerbrowser/injestdb
Http Hosting
joehand/hyperdrive-http
beakerbrowser/dathttpd
Dat Link Utilties
datprotocol/dat-dns
joehand/dat-link-resolve
pfrazee/parse-dat-url
juliangruber/dat-encoding
Dat Utilities
joehand/dat-log
mafintosh/dat-ls
karissa/hyperhealth
joehand/hyperdrive-network-speed
File Imports & Exports
juliangruber/hyperdrive-import-files
mafintosh/mirror-folder
pfrazee/hyperdrive-staging-area
pfrazee/hyperdrive-to-zip-stream
Hypercore Tools
mafintosh/hyperpipe
Dat Core Modules
mafintosh/hyperdrive
mafintosh/hypercore
CLI Utilities
joehand/dat-doctor
joehand/dat-ignore
joehand/dat-json
Networking
karissa/hyperdiscovery
mafintosh/discovery-swarm
mafintosh/webrtc-swarm
joehand/dat-swarm-defaults
Lower level networking modules
maxogden/discovery-channel
mafintosh/dns-discovery
mafintosh/multicast-dns
webtorrent/bittorrent-dht
mafintosh/utp-native
mafintosh/signalhub
Storage
datproject/dat-storage
datproject/dat-secret-storage
Random Access
juliangruber/abstract-random-access
mafintosh/multi-random-access
mafintosh/random-access-file
mafintosh/random-access-memory
mafintosh/random-access-page-files
datproject/dat-http
substack/random-access-idb
Other Related Dat Project Modules
mafintosh/peer-network
mafintosh/hyperdht
Dat Project Organization Stuff
datproject/datproject.org
datproject/discussions
datproject/design
datproject/dat-elements
kriesse/dat-colors
kriesse/dat-icons
juliangruber/dat.json
Outdated
juliangruber/dat.haus
poga/hyperfeed
yoshuawuyts/normcore
yoshuawuyts/github-to-hypercore
poga/hyperspark
juliangruber/hypercore-index
juliangruber/hyperdrive-encoding
mafintosh/hyperdrive-http-server
joehand/hyperdrive-http
joehand/dat-push
joehand/dat-backup
joehand/archiver-server
joehand/archiver-api
poga/hyperdrive-ln
substack/hyperdrive-multiwriter
substack/hyperdrive-named-archives
substack/git-dat
CfABrigadePhiladelphia/jawn
maxogden/dat-archiver
juliangruber/hyperdrive-stats
karissa/hypercore-stats-server
mafintosh/hypercore-stats-ui
karissa/zip-to-hyperdrive
joehand/url-dat
joehand/tar-dat
joehand/hyperdrive-duplicate

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