Fix bug.
This commit is contained in:
parent
baf9e093c6
commit
e0b71cec6d
|
@ -11,10 +11,12 @@ class SiteServerDbBackup
|
|||
field :need_rewrite, type: Boolean, default: true
|
||||
|
||||
before_save do
|
||||
unless @skip_callback
|
||||
if self.changed?
|
||||
self.need_rewrite = true
|
||||
end
|
||||
end
|
||||
end
|
||||
def to_crontab_script(return_string=true)
|
||||
# minute , hour, day(of month, 1~31), month(1~12), day(of week,0~6)
|
||||
crontab_time = ['*', '*', '*', '*', '*']
|
||||
|
|
|
@ -15,17 +15,21 @@ class SiteServerFileBackup
|
|||
field :need_rewrite, type: Boolean, default: true
|
||||
|
||||
before_create do
|
||||
other_rsnapshot_conf_path = self.class.pluck(:rsnapshot_conf_path)
|
||||
unless @skip_callback
|
||||
other_rsnapshot_conf_path = self.class.where(:site_server_id=>self.site_server_id).pluck(:rsnapshot_conf_path)
|
||||
if other_rsnapshot_conf_path.include?(self.rsnapshot_conf_path)
|
||||
max_postfix = other_rsnapshot_conf_path.select{|s| s.start_with?('/etc/')}.map{|s| tmp = File.basename(s).split('.conf')[0].match(/\d+/); tmp ? tmp[0].to_i : 0}.max
|
||||
self.rsnapshot_conf_path = "#{self.rsnapshot_conf_path.split('.conf')[0]}#{max_postfix + 1}.conf"
|
||||
end
|
||||
end
|
||||
end
|
||||
before_save do
|
||||
unless @skip_callback
|
||||
if self.changed?
|
||||
self.need_rewrite = true
|
||||
end
|
||||
end
|
||||
end
|
||||
def to_crontab_script
|
||||
# minute , hour, day(of month, 1~31), month(1~12), day(of week,0~6)
|
||||
crontab_time = ['*', '*', '*', '*', '*']
|
||||
|
|
|
@ -33,6 +33,7 @@ namespace :create_site do
|
|||
update_thread_infos(e.to_s)
|
||||
next
|
||||
end
|
||||
@no_stdout = true
|
||||
Net::SSH.start(@site_server.ip , @site_server.account , password: @site_server.password) do |ssh|
|
||||
certbot_path = exec_ssh_command_by_sudo_and_see_output(ssh,"bash -l -c 'which certbot certbot-auto'",false,true).strip.split("\n")[0]
|
||||
@site_server.has_certbot = certbot_path.present?
|
||||
|
@ -192,7 +193,7 @@ namespace :create_site do
|
|||
path = '/home/backup/orbit'
|
||||
end
|
||||
backup_dir_subinfo = backup_dir_info[rsnapshot_conf_path]
|
||||
tmp = file_backups_group[rsnapshot_conf_path]
|
||||
tmp = file_backups_group[rsnapshot_conf_path].to_a
|
||||
unused_period = part_retain_settings.map{|period_text, retain_count| SiteServerFileBackup::PeriodsTypes.index(period_text).to_i} - tmp.map{|time, rsnapshot_conf_path, period| period}
|
||||
unused_retain_settings = unused_period.map{|period| [period, part_retain_settings[SiteServerFileBackup::PeriodsTypes[period]]]}
|
||||
backup_dir_subinfo.each do |backup_dir, backup_prefix|
|
||||
|
@ -200,8 +201,11 @@ namespace :create_site do
|
|||
file_backup_data = {:site_server=>@site_server, :disable=>true, :period=>period, :path=>path, :retain_count=>retain_count, :rsnapshot_conf_path=>rsnapshot_conf_path, :backup_dir=>backup_dir, :backup_prefix=>backup_prefix}
|
||||
file_backup = SiteServerFileBackup.where(file_backup_data.except(:disable)).first
|
||||
if file_backup.nil?
|
||||
file_backup = SiteServerFileBackup.create(file_backup_data)
|
||||
file_backup = SiteServerFileBackup.new(file_backup_data)
|
||||
file_backup.instance_variable_set(:@skip_callback, true)
|
||||
file_backup.save
|
||||
else
|
||||
file_backup.instance_variable_set(:@skip_callback, true)
|
||||
file_backup.update_attributes(file_backup_data)
|
||||
end
|
||||
file_backup_ids << file_backup.id
|
||||
|
@ -213,7 +217,10 @@ namespace :create_site do
|
|||
file_backup = SiteServerFileBackup.where(file_backup_data.except(:disable)).first
|
||||
if file_backup.nil?
|
||||
file_backup = SiteServerFileBackup.create(file_backup_data)
|
||||
file_backup.instance_variable_set(:@skip_callback, true)
|
||||
file_backup.save
|
||||
else
|
||||
file_backup.instance_variable_set(:@skip_callback, true)
|
||||
file_backup.update_attributes(file_backup_data)
|
||||
end
|
||||
file_backup_ids << file_backup.id
|
||||
|
@ -230,7 +237,10 @@ namespace :create_site do
|
|||
db_backup = SiteServerDbBackup.where(db_backup_data.except(:disable)).first
|
||||
if db_backup.nil?
|
||||
db_backup = SiteServerDbBackup.create(db_backup_data)
|
||||
db_backup.instance_variable_set(:@skip_callback, true)
|
||||
db_backup.save
|
||||
else
|
||||
db_backup.instance_variable_set(:@skip_callback, true)
|
||||
db_backup.update_attributes(db_backup_data)
|
||||
end
|
||||
db_backup_ids << db_backup.id
|
||||
|
|
Loading…
Reference in New Issue