gofullstack / backup-cookbook Goto Github PK
View Code? Open in Web Editor NEWChef cookbook for backups
Chef cookbook for backups
I got errors from the template resource in model.rb. The first was that it complained that there was no model_path method. I fixed this by changing
path model_path
to
path ::File.join(node['backup']['model_path'], "#{new_resource.name}.rb")
This is basically copying the body of that private method into the template block.
Next I got the error that model was not a method of template. This was due to source being unquoted. I changed:
source model.erb
to:
source 'model.erb'
I have changed these in my fork (agworld user) - if this is not just user error on my behalf in some way, I am happy to make a pull request.
Right now, there's no way to set the data path for the backbook cookbook, so it ends up using a folder it creates in the user's home dir as the data folder... which is not always desirable when using the Cycler options.
I think the optimum way to do this is to make it an extra param in the backup_model. You could also just set it globally by tweaking the config.rb file.
It's not yet important for me, but I can make a PR for it if you want.
Currently, the default command ran by the cron is root backup perform --trigger my_backup --config-file /etc/backup/config.rb --log-path=/var/log > /dev/nu$
Thing is, this fail miserably because the PATH in a cron is not the same as the PATH in our shell, and the backup
command is not found.
I see two solutions here:
/usr/local/bin/backup
:path => '/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin'
My current solution is to set the path
in the cron_options
parameters, i.e
cron_options({
:path => '/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin',
:mailto => '[email protected]'
})
But this is not really straightforward, since without this, the backup-cookbook cron simply does not work :)
Thoughts?
The default cron job generated by the cookbook does not work with RVM.
If I change the command to be run inside a bash process then everything is ok (rvm will be loaded).
So I had the following in my cron:
0 * * * * backup perform --trigger my_db --config-file /etc/backup/config.rb --log-path=/var/log
and changed it to:
0 * * * * /bin/bash -l -c 'backup perform --trigger my_db --config-file /etc/backup/config.rb --log-path=/var/log'
Can you push it to opscode repository? Or if it is there, can you add link to opscode page in the README file?
Hey there,
I apologize for writing here but I can't seem to figure out how to get the cron jobs for the backup recipe to run. I can see the model actually writing the file into /etc/cron.d/...
but for some reason it does not actually run the cron job at the designated time. I'm using Ubuntu LTS 14.04.
My recipe looks like this:
# Backup
include_recipe 'backup'
backup_model :cgchannel do
description "Back up CG Channel"
definition <<-DEF
split_into_chunks_of 4000
# Removed actual backup lines for posting issue on GitHub...
######
DEF
# Daily schedule
schedule({
:minute => 0,
:hour => 0
})
end
The resulting file in /etc/cron.d/
-rw-r--r-- 1 root root 321 Jun 20 2013 updatedb.conf
# Crontab for cgchannel_backup managed by Chef. Changes will be overwritten.
0 0 * * * root backup perform --trigger cgchannel --config-file /root/Backup/config.rb --log-path=/var/log > /dev/null
So it appears that the cookbook does actually work. But for some reason the system is not actually executing this. Is there anything else I need to do to get Ubuntu to recognize the cron job?
Thanks,
Leo
Default version in the attributes is 3.0.25
, backup
has come a long way since this version, maybe we could bump to the latest?
In the example in the README I needed to change:
definition=<<-DEF
to
definition <<-DEF
The '=' character was causing a "no definition supplied" error.
The cookbook doesn’t let me set the --tmp-path
parameter and every backup gets stored in ~/Backup/
before it gets uploaded. This is an issue if you have a huge backup, but not enough space left on the device where /root/Backup/
resides.
Please add the --tmp-path
parameter as an attribute to the cookbook.
With chef-client 12.5, if you try to do this:
backup_model :jenkins_home do
...
end
You get:
ERROR: Option name must be a kind of [Symbol]! You passed "jenkins_home".
@vancluever raised this as an issue (chef/chef#4047) in the chef repo and confirmed its a problem with this cookbook.
Hi,
My cron is set, but with no recurring options at the beginning, here is the content of it:
# Crontab for alpha_backup managed by Chef. Changes will be overwritten.
[email protected]
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
root backup perform --trigger alpha --config-file /etc/backup/config.rb --log-path=/var/log > /dev/null
I have one space at the beginning, no '0 0 * * *' or anything... Here's the content of my model, pretty close to the one in the README:
backup_model node['backup']['app']['model'].to_sym do
description 'Backup Meteor database (MongoDB)'
definition <<-DEF
split_into_chunks_of 4000
database MongoDB do |db|
db.name = '#{node['backup']['app']['db']['name']}'
end
compress_with Gzip
store_with S3 do |s3|
s3.access_key_id = '#{credentials['aws_access_key_id']}'
s3.secret_access_key = '#{credentials['aws_secret_access_key']}'
s3.bucket = 'app'
s3.path = '/backups'
end
DEF
schedule({
:minute => 0,
:hour => 0
})
cron_options({
:path => '/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin',
:mailto => '[email protected]'
})
end
Any idea what's wrong @smith ? I also tried to set the minute and hour with string, i.e '0', but it didn't work...
Thanks
The model_path
is currently being computed based on the config_path
value as seen below:
default['backup']['model_path'] = "#{node['backup']['config_path']}/models"
If you change the config_path
attribute to point to something other than the /etc/backup
default then the deploy will fail. Reason being, derived attributes aren't updated when the attributes they make use of get updated. In order for the value to be set correctly you either have to manually set the derived attribute in addtion to config_path
, or use a role or environment. Since I'm using chef-solo I also have the option of setting config_path
directly in the node file, but I'd like to avoid the duplication.
As mentioned in this blog post on derived attributes, an easy fix is to simply change model_path
to be a variable that gets computed in the default recipe.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.