Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #1145 - Move issues.db to backup location configured in secrets.py #1157

Merged
merged 5 commits into from
Aug 24, 2016

Conversation

deepthivenkat
Copy link
Member

No description provided.

@deepthivenkat
Copy link
Member Author

r? @miketaylr

@@ -12,6 +12,10 @@ uploads/
.idea/
config/secrets.py

# backup folder contains the issues.db backup file with issues dump
#for the previous version of schema

This comment was marked as abuse.

@miketaylr
Copy link
Member

Note to self: it shouldn't be possible to download this backup over the web.

Double check on staging that this is the case (it should be, according to https://github.com/webcompat/webcompat.com/blob/master/CONTRIBUTING.md#production-server-setup)

elif STAGING:
BACKUP_DEFAULT_DEST = ''
BACKUP_DEFAULT_URL = ''
elif LOCALHOST:

This comment was marked as abuse.

@miketaylr
Copy link
Member

Can we squash the "fixing merge conflicts" commit into the first one?

Thanks!

@deepthivenkat deepthivenkat force-pushed the issues/1145/1 branch 2 times, most recently from 71a8587 to 1e6f8c3 Compare August 9, 2016 04:45
try:
os.remove(os.path.join(os.getcwd(), 'issues.db'))
except OSError:
print 'Backup issues.db complete'

This comment was marked as abuse.

This comment was marked as abuse.

@deepthivenkat
Copy link
Member Author

r? @miketaylr @karlcow

else:
print 'Backup db folder exists'
current_ts = time.time()
time_stamp = datetime.datetime.fromtimestamp(current_ts).strftime('%Y-%m-%d-%H:%M:%S')

This comment was marked as abuse.

This comment was marked as abuse.

print idx
if idx < no_of_backup_files - 3:
os.remove(app.config['BACKUP_DEFAULT_DEST'] + val)
backup_files = os.listdir(app.config['BACKUP_DEFAULT_DEST'])

This comment was marked as abuse.

bind=issue_engine)
issue_db = scoped_session(issue_session_maker)
# Take a backup if issues.db has data dump.
if issue_db().execute('select count(*) from webcompat_issues').fetchall()[0][0] > 0:

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

@deepthivenkat
Copy link
Member Author

r? @karlcow

bind=issue_engine)
issue_db = scoped_session(issue_session_maker)
# Take a backup if issues.db has data dump.
# TODO: write code for creating issues dump in the issues.db with updated schema

This comment was marked as abuse.

This comment was marked as abuse.

@karlcow
Copy link
Member

karlcow commented Aug 22, 2016

it's in a lot better shape. Thanks @deepthivenkat
And could be almost finished except for a couple of things (TODO, messages, etc) if we focus on just doing the backup and not migration schema.

@@ -12,6 +12,10 @@ uploads/
.idea/
config/secrets.py

# backup folder contains the issues.db backup file with issues dump
# for the previous version of schema

This comment was marked as abuse.

@miketaylr
Copy link
Member

LGTM, just need to update some comments and tweak the print stuff!

@miketaylr
Copy link
Member

Trying to run this locally with python run.py --backup and I don't get a backup folder created. Does it for you @deepthivenkat? I would assume there would be a /backup dir created in my project root.

@deepthivenkat
Copy link
Member Author

deepthivenkat commented Aug 24, 2016

@miketaylr The backup folder will get created only if the issues.db has a data dump.
I am creating the folder only when I have to move the db file to the backup folder. Otherwise, there will be only an empty folder with no content.

I have also made the comment change in secrets.py.example and have run pep8. Ready for merging :)

@miketaylr
Copy link
Member

The backup folder will get created only if the issues.db has a data dump.
I am creating the folder only when I have to move the db file to the backup folder.

Ah, OK!

I think we should add some print statements so it's less confusing like: "Not doing a backup because there's nothing to back up!" (or whatever). But let's file a follow-up issue for that.

@miketaylr
Copy link
Member

We can ignore travis failures here, seems good to merge. 👍

@miketaylr miketaylr merged commit 9736949 into webcompat:master Aug 24, 2016
@miketaylr
Copy link
Member

Oops, forgot that we should have had a "Fixes #1145" in the PR title. Something to remember for the future @deepthivenkat :)

MDTsai added a commit to MDTsai/webcompat.com that referenced this pull request Jan 25, 2017
Follow-up of issue webcompat#1157, print message if there is nothing to backup
to BACKUP_DEFAULT_DEST

Issue webcompat#1294 - Check BAKCUP_DEFAULT_DEST before backup

Also fix the syntax, no warning using PEP8 check.
MDTsai added a commit to MDTsai/webcompat.com that referenced this pull request Jan 25, 2017
Follow-up of issue webcompat#1157, print message if there is nothing to backup
to BACKUP_DEFAULT_DEST

Issue webcompat#1294 - Check BAKCUP_DEFAULT_DEST before backup

Also fix the syntax, no warning using PEP8 check.
MDTsai added a commit to MDTsai/webcompat.com that referenced this pull request Jan 25, 2017
Follow-up of issue webcompat#1157, print message if there is nothing to backup
to BACKUP_DEFAULT_DEST

Issue webcompat#1294 - Check BAKCUP_DEFAULT_DEST before backup

Also fix the syntax, no warning using PEP8 check.
MDTsai added a commit to MDTsai/webcompat.com that referenced this pull request Jan 25, 2017
Follow-up of issue webcompat#1157, print message if there is nothing to backup
to BACKUP_DEFAULT_DEST

Issue webcompat#1294 - Check BAKCUP_DEFAULT_DEST before backup

Also fix the syntax, no warning using PEP8 check.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants