Question

I'm using the backup gem (4.0.1) and when I run the backup it runs twice. I only have one backup model:

Backup::Model.new(:pais3_prod_backup, 'PAIS 3 production server & database backup') do

  split_into_chunks_of 2000

  archive :my_archive do |archive|
    # Run the `tar` command using `sudo`
    archive.use_sudo
    archive.add "/etc"
    archive.add "/srv"
    archive.exclude "/home/map7/Backup/.tmp"
    archive.exclude "/home/map7/.cache"    
  end
end

I run this manually with the following command

backup perform -t pais3_prod_backup

Although twice is better than none at all, I'm left wondering why is it running twice? Where do I start debugging this?

Was it helpful?

Solution

If I had to guess, make sure there are no require/include/instance_eval of the :pais3_prod_backup model file in your backup config.rb (or some include of all models from models/ folder).

I fell for it when upgrading from version 3.x to 4.x, and it took me several hours to figure out why all my models are running twice. I solved it by removing the following code from my config.rb:

# Load all models from the models directory (after the above global configuration blocks)
Dir[File.join(File.dirname(Config.config_file), "models", "*.rb")].each do |model|
  instance_eval(File.read(model))
end
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top