using this gem is no longer needed since Duplicati GUI allows for command line export from the GUI itself.
This gem is a Duplicati backup utility wrapper written in Ruby with easier API and sensible configuration defaults compared to Duplicati's own utilities.
- Install Duplicati itself.
- Install Duplicati gem.
Add this line to your application's Gemfile:
gem 'duplicati'
And then execute:
$ bundle
Or install it yourself as:
$ gem install duplicati
require "duplicati"
Duplicati.backup(
:backup_paths => ["/foo/bar", "/foo/baz"],
:backup_store_path => "file:///backup",
:backup_encryption_key => "very-secret-key"
)
Refer to Duplicati documentation for different backup store locations.
Duplicati allows to specify inclusion and exclusion filters when it comes to backups, restoring and so on.
It has quite complex filtering API, which this gem tries to simplify.
To include only .txt files, you need to write this:
Duplicati.backup(:inclusion_filter => /.*\.txt$/)
Globs are also supported:
Duplicati.backup(:inclusion_filter => "*.mp3")
It is also possible to have multiple filters:
Duplicati.backup(:inclusion_filters => [/.*\.txt$/, "*.mp3"])
Exclusion filters work similarly:
Duplicati.backup(:exclusion_filter => "*.exe")
Duplicati gem supports currently two different notifications.
Growl notifications are enabled by default if not specified otherwise.
For these to work you need to install Growl or Growl for Windows and a ruby_gntp gem.
You can enable Growl notifications manually by specifying :notifications
option like this:
Duplicati.backup(
:notifications => [Duplicati::Notification::Growl.new],
# other options
)
To use e-mail notifications, you need to install mail gem.
After that you need to specify :notifications
option like this:
Duplicati.backup(
:notifications => [
Duplicati::Notification::Mail.new(
:to => "recipient@example.com",
:smtp_config => { :domain => "example.com", :address => "mail.example.com" }
)
],
# other options
)
You can use multiple notifications together by specifying them in the :notifications
option array:
Duplicati.backup(:notifications => [NotificationClass1.new, NotificationClass2.new, ...])
To disable all notifications, you need to pass an empty array to :notifications
option:
Duplicati.backup(:notifications => [])
It is really easy to add new notification types by just implementing one class with single method called #notify
.
This method takes a single boolean argument called success
which will be true if the Duplicati command succeeded
and false otherwise. For example:
class CustomNotification
def notify(success)
if success
# notify with success message
else
# notify with failure message
end
end
end
Duplicati has a #execution_success?
method for determining the success
status of backup command:
Duplicati.backup(options).execution_success? # => "true" when execution was a success.
It is possible to execute commands separately when needed:
Duplicati.backup(options).execution_success?
# is same as
Duplicati.new(options).backup.clean.notify.execution_success?
- Currently only backup is supported. Use Duplicati's command line or GUI utility directly for restoring.
- You need to start Ruby with administrative privileges under Windows to backup files in use.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request