Reset backup canaries
This commit is contained in:
parent
3f34a3aaf8
commit
cad4caf518
|
@ -29,6 +29,7 @@ class Command(BaseCommand):
|
||||||
@transaction.atomic
|
@transaction.atomic
|
||||||
def generate_backups(self):
|
def generate_backups(self):
|
||||||
backup_users = secrets.BACKUP_TOKENS.values()
|
backup_users = secrets.BACKUP_TOKENS.values()
|
||||||
|
count = 0
|
||||||
|
|
||||||
for user in backup_users:
|
for user in backup_users:
|
||||||
models.MetaInfo.objects.update_or_create(
|
models.MetaInfo.objects.update_or_create(
|
||||||
|
@ -40,6 +41,9 @@ class Command(BaseCommand):
|
||||||
with open(DATA_FOLDER + '/static/123e4567-e89b-12d3-a456-426655440000.jpg', 'w') as f:
|
with open(DATA_FOLDER + '/static/123e4567-e89b-12d3-a456-426655440000.jpg', 'w') as f:
|
||||||
f.write(backup_id_string(user) + '\n')
|
f.write(backup_id_string(user) + '\n')
|
||||||
|
|
||||||
|
if user['name'] == 'null': # reset the canaries for data-at-rest
|
||||||
|
continue
|
||||||
|
|
||||||
file_name = 'spaceport-backup-{}.tar.gz'.format(
|
file_name = 'spaceport-backup-{}.tar.gz'.format(
|
||||||
str(now().date()),
|
str(now().date()),
|
||||||
)
|
)
|
||||||
|
@ -72,8 +76,9 @@ class Command(BaseCommand):
|
||||||
cache.set(user['cache_key'], path_name + '/' + file_name)
|
cache.set(user['cache_key'], path_name + '/' + file_name)
|
||||||
|
|
||||||
self.stdout.write('Wrote backup for: ' + user['name'])
|
self.stdout.write('Wrote backup for: ' + user['name'])
|
||||||
|
count += 1
|
||||||
|
|
||||||
return len(backup_users)
|
return count
|
||||||
|
|
||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
self.stdout.write('{} - Generating backups'.format(str(now())))
|
self.stdout.write('{} - Generating backups'.format(str(now())))
|
||||||
|
|
|
@ -75,12 +75,17 @@ EMAIL_PASS = ''
|
||||||
# head /dev/urandom | base32 | head -c 40
|
# head /dev/urandom | base32 | head -c 40
|
||||||
BACKUP_TOKENS = {
|
BACKUP_TOKENS = {
|
||||||
'<token>': {
|
'<token>': {
|
||||||
'name': 'firstname_lastname',
|
'name': 'firstname.lastname',
|
||||||
'backup_id': '<token>',
|
'backup_id': '<token>',
|
||||||
'cache_key': '<token>',
|
'cache_key': '<token>',
|
||||||
},
|
},
|
||||||
'<token>': {
|
'<token>': {
|
||||||
'name': 'firstname_lastname',
|
'name': 'firstname.lastname',
|
||||||
|
'backup_id': '<token>',
|
||||||
|
'cache_key': '<token>',
|
||||||
|
},
|
||||||
|
'<token>': { # reset the canaries for data-at-rest
|
||||||
|
'name': 'null',
|
||||||
'backup_id': '<token>',
|
'backup_id': '<token>',
|
||||||
'cache_key': '<token>',
|
'cache_key': '<token>',
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue
Block a user