{"id":13541094,"url":"https://github.com/joehand/dat-backup","last_synced_at":"2025-10-25T10:39:13.875Z","repository":{"id":141530451,"uuid":"76799942","full_name":"joehand/dat-backup","owner":"joehand","description":"Create and share static backups of a Dat archive.","archived":false,"fork":false,"pushed_at":"2017-05-22T17:57:46.000Z","size":32,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-10T10:53:28.465Z","etag":null,"topics":["dat"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joehand.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2016-12-18T18:39:15.000Z","updated_at":"2020-05-19T03:10:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"8aae67be-09a2-4f5e-85ce-4523f705ad0f","html_url":"https://github.com/joehand/dat-backup","commit_stats":{"total_commits":19,"total_committers":2,"mean_commits":9.5,"dds":0.3157894736842105,"last_synced_commit":"28d1860561a33b3891bddb1adfcae9218b4d963f"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joehand%2Fdat-backup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joehand%2Fdat-backup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joehand%2Fdat-backup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joehand%2Fdat-backup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joehand","download_url":"https://codeload.github.com/joehand/dat-backup/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247280176,"owners_count":20912965,"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":["dat"],"created_at":"2024-08-01T10:00:38.415Z","updated_at":"2025-10-25T10:39:08.826Z","avatar_url":"https://github.com/joehand.png","language":"JavaScript","readme":"# dat-backup\n\nBackup a dat to local storage. Useful for:\n\n* Storing full history\n* Creating local backups of data (good for offline backups!)\n* More efficient storage (all content, latest and historic, is stored as a single `content.data` file)\n\n## Usage\n\nA 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.\n\n```js\nvar createBackup = require('dat-backup')\n\nvar archive = hyperdrive('/dir', {latest: true}) // some existing archive or dat-node instance\n\n// default dir is ~/.dat/backups/\u003cdiscovery-key\u003e\nvar backup = createBackup(archive, {dir: '/big-hd/' + archive.discoveryKey.toString('hex')})\n\nbackup.ready(function (err) {\n  if (err) throw err\n\n  // backup archive at current version\n  backup.add(function () {\n  \tconsole.log('archive backed up at version: ', archive.version)\n  })\n\n  // List all file versions available in archive backup\n  backup.list(function (err, files) {\n    if (err) throw err\n    console.log(files)\n  })\n})\n```\n\n## API\n\n### `var backup = createBackup(source, [opts])`\n\n`source` is either a hyperdrive `archive` or dat-node instanace, `dat`.\n\nOptions are:\n\n* `opts.dir`: where to store backups, defaults to `~/.dat/backup/discKey.slice(0, 2), discKey.slice(2)`\n\n#### `backup.ready()`\n\nInitalize 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()`.\n\n#### `backup.add([opts], cb)`\n\nCreate 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.\n\nOptions are:\n\n* `opts.live`: Do a live backup, backing up content as it is updated. Will not callback.\n\n#### `backup.remove(start, [end], cb)`\n\nRemove archive version(s) from local backup.\n\nStart and end have the following properties: `{version: 0}`. `end.version` defaults to `start.version + 1`.\n\nYou can also pass *content* block numbers directly (equivilant to `archive.content.clear(start, end, cb)`).\n\n#### `var stream = backup.list([opts], [cb])`\n\nList all data available in backup. Streams a list of files from `archive.history()` if they are backed up. `opts` are passed to `archive.history`.\n\nIf `cb` is provided, stream will collect the list and callback with `(err, list)`.\n\n#### `backup.serve()`\n\nServe data from a backup. This will allow users to download any data that is backed up.\n\n## License\n\nMIT\n","funding_links":[],"categories":["Outdated"],"sub_categories":["Other Related Dat Project Modules"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoehand%2Fdat-backup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoehand%2Fdat-backup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoehand%2Fdat-backup/lists"}