--- /dev/null
+= DESCRIPTION:
+
+= REQUIREMENTS:
+
+= ATTRIBUTES:
+
+= USAGE:
+
--- /dev/null
+default[:stats][:sites] = []
--- /dev/null
+#!/usr/bin/perl
+
+# DO NOT EDIT - This file is being maintained by Chef
+
+use strict;
+use warnings;
+
+use Date::Calc qw(Today Add_Delta_Days Add_Delta_YMD Day_of_Week);
+use Getopt::Long;
+
+my $days = 0;
+my $weeks = 0;
+my $months = 0;
+
+GetOptions("days=i" => \$days, "weeks=i" => \$weeks, "months=i" => \$months);
+
+my $dir = shift;
+my $prefix = shift;
+my @dates;
+
+for my $day (0 .. $days - 1)
+{
+ push(@dates, sprintf("%04d-%02d-%02d", Subtract_Delta_Days(Today(), $day)));
+}
+
+for my $week (0 .. $weeks - 1)
+{
+ push(@dates, sprintf("%04d-%02d-%02d", Subtract_Delta_Days(Monday(), $week * 7)));
+}
+
+for my $month (0 .. $months - 1)
+{
+ push(@dates, sprintf("%04d-%02d-%02d", Subtract_Delta_YMD(First_of_Month(), 0, $month, 0)));
+}
+
+my $dates = join("|", @dates);
+my $match = qr/^${prefix}-\d{4}-\d{2}-\d{2}\./;
+my $keep = qr/^${prefix}-(?:${dates})\./;
+
+opendir(DIR, "$dir") || die "Can't open ${dir}: $!";
+
+while (my $file = readdir(DIR))
+{
+# print "Expiring $file\n" if $file =~ $match && $file !~ $keep;
+ unlink("${dir}/${file}") if $file =~ $match && $file !~ $keep;
+}
+
+closedir(DIR);
+
+exit 0;
+
+sub Monday
+{
+ my @today = Today();
+
+ return Subtract_Delta_Days(@today, Day_of_Week(@today) - 1);
+}
+
+sub First_of_Month
+{
+ my($year,$month,$day) = Today();
+
+ return($year,$month,1);
+}
+
+sub Subtract_Delta_Days
+{
+ my $year = shift;
+ my $month = shift;
+ my $day = shift;
+ my $days = shift;
+
+ return Add_Delta_Days($year, $month, $day, -$days);
+}
+
+sub Subtract_Delta_YMD
+{
+ my $year = shift;
+ my $month = shift;
+ my $day = shift;
+ my $years = shift;
+ my $months = shift;
+ my $days = shift;
+
+ return Add_Delta_YMD($year, $month, $day, -$years, -$months, -$days);
+}
--- /dev/null
+maintainer "OpenStreetMap Administrators"
+maintainer_email "admins@openstreetmap.org"
+license "Apache 2.0"
+description "Installs and configures backup.openstreetmap.org"
+long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc'))
+version "1.0.0"
--- /dev/null
+#
+# Cookbook Name:: backup
+# Recipe:: default
+#
+# Copyright 2013, OpenStreetMap Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+directory "/store/backup" do
+ owner "osmbackup"
+ group "osmbackup"
+ mode 02755
+end
+
+cookbook_file "/usr/local/bin/expire-backups" do
+ owner "root"
+ group "root"
+ mode 0755
+end
+
+template "/etc/cron.daily/expire-backups" do
+ source "expire.cron.erb"
+ owner "root"
+ group "root"
+ mode 0644
+end
--- /dev/null
+#!/bin/sh
+
+# DO NOT EDIT - This file is being maintained by Chef
+
+for prefix in chef git lists osmf-blog osmf-crm osmf-ledgersmb osmf-wiki osqa otrs sotm svn trac wiki
+do
+ /usr/local/bin/expire-backups --days=3 --weeks=3 --months=3 /store/backup $prefix
+done
+
+/usr/local/bin/expire-backups --weeks=5 /store/backup osm
--- /dev/null
+name "backup"
+description "Role applied to backup.openstreetmap.org"
+
+default_attributes(
+ :accounts => {
+ :users => {
+ :osmbackup => { :status => :role }
+ }
+ },
+ :rsyncd => {
+ :modules => {
+ :backup => {
+ :comment => "Backups",
+ :path => "/store/backup",
+ :read_only => false,
+ :write_only => true,
+ :list => false,
+ :uid => "osmbackup",
+ :gid => "osmbackup",
+ :transfer_logging => false,
+ :hosts_allow => [
+ "128.40.168.0/24", # ucl external
+ "146.179.159.160/27", # ic internal
+ "193.63.75.96/27", # ic external
+ "2001:630:12:500::/64", # ic external
+ "127.0.0.0/8", # localhost
+ "::1" # localhost
+ ]
+ }
+ }
+ }
+)
+
+run_list(
+ "recipe[rsyncd]",
+ "recipe[backup]"
+)
default_attributes(
:accounts => {
:users => {
- :osmbackup => { :status => :role },
:gravitystorm => { :status => :user }
}
},
"127.0.0.0/8", # localhost
"::1" # localhost
]
- },
- :backup => {
- :comment => "Backups",
- :path => "/store/backup",
- :read_only => false,
- :write_only => true,
- :list => false,
- :uid => "osmbackup",
- :gid => "osmbackup",
- :transfer_logging => false,
- :hosts_allow => [
- "128.40.168.0/24", # ucl external
- "146.179.159.160/27", # ic internal
- "193.63.75.96/27", # ic external
- "2001:630:12:500::/64", # ic external
- "127.0.0.0/8", # localhost
- "::1" # localhost
- ]
}
}
}
"role[planet]",
"role[stats]",
"role[web-storage]",
+ "role[backup]",
"recipe[rsyncd]",
"recipe[openvpn]"
)