Archivault
ArchiVault is a Ruby gem for Rails applications that backs up files, logs, and databases using paths and credentials provided by the app. It compresses and encrypts the data, then uploads it securely to AWS S3.
Installation
Install the gem and add to the application's Gemfile by executing:
bundle add archivaultIf bundler is not being used to manage dependencies, install the gem by executing:
gem install archivaultRuby usage
SQLite database backup
database_path = "/home/user/app/storage/production.sqlite3"
gpg_passphrase = "password"
s3_setup = {
region: "region",
access_key_id: "access_key_id",
secret_access_key: "secret_access_key",
bucket: "bucket"
}
ping_url = "https://example.com/ping" # optional parameter
Archivault::SqliteBackup.new(database_path:, gpg_passphrase:, s3_setup:, ping_url:).callPostgreSQL database backup
database_url = "postgres://user:password@localhost:5432/mydb"
gpg_passphrase = "password"
s3_setup = {
region: "region",
access_key_id: "access_key_id",
secret_access_key: "secret_access_key",
bucket: "bucket"
}
ping_url = "https://example.com/ping" # optional parameter
Archivault::PostgresqlBackup.new(database_url:, gpg_passphrase:, s3_setup:, ping_url:).callLogs backup
log_path_or_paths = %w[
/home/user/app/log/production.log.1
/home/user/app/log/nginx_access.log.1
]
gpg_passphrase = "password"
s3_setup = {
region: "region",
access_key_id: "access_key_id",
secret_access_key: "secret_access_key",
bucket: "bucket"
}
ping_url = "https://example.com/ping" # optional parameter
Archivault::LogsBackup.new(log_path_or_paths:, gpg_passphrase:, s3_setup:, ping_url:).callRails usage
SQLite database backup
# in config/credentials.yml.enc
# archivault:
# gpg_passphrase: password
# s3_setup:
# region: region
# access_key_id: access_key_id
# secret_access_key: secret_access_key
# bucket: bucket
params = {
database_path: Rails.root.join("storage/production.sqlite3"),
ping_url: "https://example.com/ping" # optional parameter
}.merge(Rails.application.credentials.archivault)
Archivault::SqliteBackup.new(**params).callPostgreSQL database backup
# in config/credentials.yml.enc
# archivault:
# gpg_passphrase: password
# s3_setup:
# region: region
# access_key_id: access_key_id
# secret_access_key: secret_access_key
# bucket: bucket
params = {
database_url: ENV["DATABASE_URL"],
ping_url: "https://example.com/ping" # optional parameter
}.merge(Rails.application.credentials.archivault)
Archivault::PostgresqlBackup.new(**params).callLogs backup
# in config/credentials.yml.enc
# archivault:
# gpg_passphrase: password
# s3_setup:
# region: region
# access_key_id: access_key_id
# secret_access_key: secret_access_key
# bucket: bucket
params = {
log_path_or_paths: Rails.root.join("log", "production.log.1"),
ping_url: "https://example.com/ping" # optional parameter
}.merge(Rails.application.credentials.archivault)
Archivault::LogsBackup.new(**params).callDevelopment
After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/macuk/archivault. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
License
The gem is available as open source under the terms of the MIT License.
Code of Conduct
Everyone interacting in the Archivault project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.