This repository was archived by the owner on Aug 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
96 lines (70 loc) · 2.9 KB
/
config.py
File metadata and controls
96 lines (70 loc) · 2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# config.py - Configuration info for s3backup et al
# Copyright 2012 Ryan Frame
# 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.
# TODO: Write cron example in Readme
# TODO: Find a good os.nice value so we don't slow things down on a busy
# system
from ConfigParser import SafeConfigParser
import os
scp = SafeConfigParser()
scp.read('s3backup.conf')
# Suite version
version = '0.9'
# === Company Settings === #
# Company / software name. Used as prefix for logging, eg:
# name.s3Backup ....
company = scp.get('Company', 'company')
# === AWS Settings === #
# Read the keys from a file; The first is the access key, the second is
# the secret key
keypath = scp.get('AWS', 'keypath')
with open(keypath, 'r') as inf:
aws_access_key_id = inf.readline().strip()
aws_secret_access_key = inf.readline().strip()
bucket = scp.get('AWS', 'bucket_name')
machine_name = scp.get('AWS', 'machine_name')
# === Directory / Filesystem settings === #
base_dir = scp.get('Directory', 'base_directory')
daily_backup_list = os.path.join(base_dir, scp.get('Directory',
'daily_list'))
weekly_backup_list = os.path.join(base_dir, scp.get('Directory',
'weekly_list'))
monthly_backup_list = os.path.join(base_dir, scp.get('Directory',
'monthly_list'))
dest_location = scp.get('Directory', 'destination')
log_file = scp.get('Directory', 'log_path')
hash_file_path = scp.get('Directory', 'hash_file_path')
# === Backup settings === #
log_raise_errs = scp.get('Backup', 'raise_log_errors')
# Note: this deletes the entire dest_location folder
delete_archive_when_finished = scp.get('Backup', 'delete_archive')
pass_hash = scp.get('Backup', 'passwd_hash_type')
# Import the proper module and initialize pass_hash
if pass_hash == 'SHA512':
from Crypto.Hash import SHA512
pass_hash = SHA512.new()
elif pass_hash == 'MD5':
from Crypto.Hash import MD5
pass_hash = MD5.new()
elif pass_hash == 'SHA256':
from Crypto.Hash import SHA256
pass_hash = SHA256.new()
else:
from Crypto.Hash import SHA
pass_hash = SHA.new()
# We hash a memorable password for the encryption key
enc_backup = scp.get('Backup', 'use_encryption')
enc_password = scp.get('Backup', 'encryption_password')
pass_hash.update(enc_password)
enc_key = pass_hash.digest()[0:32] # Use the first 32 bits
enc_piece_size = 1024*64
# Supported compression methods are none, gz, bz2, and zip
compression_method = scp.get('Backup', 'compression')