2021-06-19 12:24:33 -06:00
|
|
|
#!/usr/bin/python3
|
2011-05-18 14:36:31 -04:00
|
|
|
import os
|
2011-05-18 14:59:05 -04:00
|
|
|
import shutil
|
2011-05-18 14:36:31 -04:00
|
|
|
|
2021-06-19 12:02:29 -06:00
|
|
|
from newsblur_web import settings
|
|
|
|
import boto3
|
|
|
|
|
|
|
|
filenames = [f for f in os.listdir('/opt/mongo/newsblur/backup/') if '.tgz' in f]
|
|
|
|
|
2021-06-27 14:32:37 -06:00
|
|
|
for filename in filenames:
|
2021-06-19 12:02:29 -06:00
|
|
|
print('Uploading %s to S3...' % filename)
|
|
|
|
try:
|
2021-07-23 19:04:30 -04:00
|
|
|
s3 = boto3.client('s3')
|
|
|
|
bucket = s3.Bucket()
|
|
|
|
bucket.upload_file(f"mongo/{filename}", settings.S3_BACKUP_BUCKET)
|
2021-06-19 12:02:29 -06:00
|
|
|
except Exception as e:
|
|
|
|
print(" ****> Exceptions: %s" % e)
|
|
|
|
shutil.rmtree(filename[:-4])
|
|
|
|
os.remove(filename)
|