Created
June 21, 2014 08:18
-
-
Save alenbasic/ac18751d62890e63f4f9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import dropbox | |
import time | |
import os | |
APP_KEY = '' | |
APP_SECRET = '' | |
ACCESS_TOKEN = "" | |
TIMESTAMP = time.strftime('%Y-%m-%d') | |
FILENAME = "filename.sql" | |
TAR_XZ = "filename_" + TIMESTAMP +".tar.xz" | |
flow = dropbox.client.DropboxOAuth2FlowNoRedirect(APP_KEY, APP_SECRET) | |
client = dropbox.client.DropboxClient(ACCESS_TOKEN) | |
try: | |
os.popen("mysqldump -u username -pPASSWORD --single-transaction database_name > " + FILENAME) | |
os.popen("tar -jcf " + TAR_XZ + " " + FILENAME) | |
os.popen("rm " + FILENAME) | |
f = open(TAR_XZ, 'rb') | |
response = client.put_file('/folder/' + TAR_XZ, f) | |
f.close() | |
os.popen("rm " + TAR_XZ) | |
os.popen('echo "" | mail -s "Dropbox: Upload Successful" [email protected]) | |
except Exception: | |
os.popen('echo "" | mail -s "Dropbox: Error. Please investigate." [email protected]') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment