diff --git a/chef/cookbooks/common/files/default/backupcron.txt b/chef/cookbooks/common/files/default/backupcron.txt new file mode 100644 index 000000000..acd11f4f3 --- /dev/null +++ b/chef/cookbooks/common/files/default/backupcron.txt @@ -0,0 +1 @@ +29 23 * * * exec /usr/local/app/diaspora/script/backup 2>> /tmp/backup/errors.log diff --git a/chef/cookbooks/common/recipes/backup.rb b/chef/cookbooks/common/recipes/backup.rb new file mode 100644 index 000000000..bb95c3ba6 --- /dev/null +++ b/chef/cookbooks/common/recipes/backup.rb @@ -0,0 +1,7 @@ +execute "Remove Any Pervious Cronjob" do + command "crontab -r || true" +end + +execute "Add the current cronjob" do + command "crontab /usr/local/app/diaspora/chef/files/default/backupcorn.txt" +end diff --git a/chef/cookbooks/common/recipes/main.rb b/chef/cookbooks/common/recipes/main.rb index a996cb162..cbaf76f9e 100644 --- a/chef/cookbooks/common/recipes/main.rb +++ b/chef/cookbooks/common/recipes/main.rb @@ -2,3 +2,4 @@ include_recipe "common::iptables" include_recipe "common::daemontools" include_recipe "common::secret_token" include_recipe "common::splunk" +include_recipe "common::backup" diff --git a/script/backup b/script/backup new file mode 100755 index 000000000..fea2e1418 --- /dev/null +++ b/script/backup @@ -0,0 +1,6 @@ +#!/bin/bash + +cd /usr/local/app/diaspora/ +touch /usr/local/app/diaspora/backup_start.txt +exec /usr/local/bin/ruby /usr/local/bin/bundle exec rake backup:mongo 2>> /tmp/backup/rake.log +touch /usr/local/app/diaspora/backup_end.txt