Skip to content
Brian D. Burns edited this page Dec 13, 2011 · 11 revisions

Archives

Archives support:

  • Files
  • Directories

Examples

The following examples should be placed in your Backup configuration file.

Backup::Model.new(:my_backup, 'My Backup') do
  # examples go here...
end

Files and Folders

The following creates a single .tar file called my_archive.tar

archive :my_archive do |archive|
  # add a file
  archive.add '/path/to/a/file.rb'
  # add a folder (including sub-folders)
  archive.add '/path/to/a/folder/'
  # exclude a file
  archive.exclude '/path/to/a/excluded_file.rb'
  # exclude a folder (including sub-folders)
  archive.exclude '/path/to/a/excluded_folder/'
end
  • You can archive as many files and folders as you like within the archive block
  • You can have as many archive blocks as you like within your configuration file

Additional Tar Options

Archives also have a tar_options method, which can be used to add additional options to the tar command used to create the archive.

For example, to have tar follow symlinks and store extended attributes, you could use:

archive :my_archive do |archive|
  archive.add '/path/to/a/file.rb'
  archive.tar_options '-h --xattrs'
end

The options available for tar will depend on your system. See tar --help or man tar for details.

Note: It is not recommended that you add compression flags using tar_options. The next version of backup will automatically pipe the output of the archive's tar command through the Compressor configured using the compress_with block.

Clone this wiki locally