Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dev_archive

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dev_archive

  • 0.1.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

DevArchive

Save and restore snapshots of stateful services to a central archive. Have a development database that you want to restore to a prior state? Just take a snapshot and restore it later!

Backup

# Uses your EDITOR to add details for the snapshot.
# Uses the default configured "stores" for creating the snapshot
dev_archive backup

# Add a message from the command line:
dev_archive backup --message "Add message from command line"
dev_archive backup -m "Add message from command line"

# Override which stores are used for the snapshot
dev_archive --store custom_store_1,custom_store_2

See the "Configure" section for how add a custom store.

Show

# Show the full details for a given snapshot
dev_archive show {id}

Restore

# Restore the given snapshot
dev_archive restore {id}

List

# list all snapshots (pipe to `less` if you like)
dev_archive list

Delete

# Delete the given snapshot
dev_archive rm {id}

Configure

A custom configuration can be written at the location $HOME/.config/dev_archive.rb. It is written in ruby. Here is an example config:


DevArchive.configure do |config|

  # Configure where the snapshots are stored. Defaults to `$HOME/.dev_archive`
  config.storage_path = "/path/to/snapshot_dir"

  # Configure which stores are active by default (can be overridden with --store
  # option on command line). The default store is "mysql_rails" which saves a
  # snapshot of all databases for the Rails app found in the CWD.
  config.active_stores = ["store_1", "store_2"]

  # Creating a custom store:
  #
  # Stores must implement two methods:
  #
  #   backup: accepts a directory for data and returns a JSON hash (with string
  #     keys) for use in restoring.
  #
  #  restore: accepts the metadata JSON data created when making the backup. No
  #    return value.
  #
  # Stores can either be defined as objects/classes/modules or a builtin store
  # builder can be used.

  # Using an object:

  class MyCustomStore
    def backup(dir)
      path = File.join(dir, "my_custom_store.txt")
      File.write(path, "hello")

      { "path" => path }
    end

    def restore(metadata)
      puts(File.read(metadata.fetch("path")))
    end
  end

  config.register_store("my_custom_store", MyCustomStore.new)


  # Using the store builder:

  config.register_store("my_customer_store") do |store|
    store.backup do |dir|
      path = File.join(dir, "my_custom_store.txt")
      File.write(path, "hello")

      { "path" => path }
    end

    store.restore do |metadata|
      puts(File.read(metadata.fetch("path")))
    end
  end
end

FAQs

Package last updated on 08 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc