简体   繁体   English

ruby backup gem运行两次

[英]ruby backup gem runs twice

I'm using the backup gem (4.0.1) and when I run the backup it runs twice. 我正在使用备份gem(4.0.1),当我运行备份时,它会运行两次。 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? 我从哪里开始调试?

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). 如果我不得不猜测,请确保备份config.rb中没有:pais3_prod_backup模型文件的require / include / instance_eval(或某些包含models /文件夹中所有模型的文件)。

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. 从版本3.x升级到4.x时,我感到很沮丧,我花了几个小时来弄清楚为什么我的模型都运行了两次。 I solved it by removing the following code from my config.rb: 我通过从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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM