Last active
January 1, 2018 19:15
-
-
Save limhenry/1adfb64a4a48840a76d2 to your computer and use it in GitHub Desktop.
Firebase Backup Script with Python
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
#Firebase Auto Backup by Henry Lim (https://limhenry.xyz) | |
#WARNING: THIS MIGHT AGAINST FIREBASE'S TERMS OF SERVICE, USE IT AT YOUR OWN RISK | |
#Just change the line with comment | |
import urllib | |
import urllib2 | |
from time import gmtime, strftime | |
import time | |
timeinseconds = 60 #Run the script every 60 seconds, recommend to change it to > 15 mins | |
firebaseID = "YOURFIREBASEID" #Change this to your Firebase ID | |
auth = False #Change to True if you database required authentication | |
if auth: | |
token = "YOURFIREBASETOKEN" #Your Firebase Token: Get the token from https://YOURFIREBASEID.firebaseio.com/?page=Admin | |
firebaseURL = "https://" + firebaseID + ".firebaseio.com//.json?auth=" + token | |
else: | |
firebaseURL = "https://" + firebaseID + ".firebaseio.com//.json" | |
while True: | |
print firebaseURL | |
print strftime("%Y%m%d_%H%M%S", gmtime()) | |
time.sleep(timeinseconds) | |
filename = "firebase" + strftime("%Y%m%d_%H%M%S", gmtime()) + ".json" | |
testfile = urllib.URLopener() | |
testfile.retrieve(firebaseURL, filename) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment