Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Moved creating the database path and filename to the processSql funct…

…ion so we can add the provider to the filename. It will now take look like provider_filename.sql, and will take filename as an argument to the method.
  • Loading branch information...
commit 950becdb2271314b7baff3b3f66c44196deb2ca1 1 parent 5905f94
@Lateral-October authored
Showing with 11 additions and 7 deletions.
  1. +2 −2 backup_sources/databases/mysql.py
  2. +9 −5 sql.py
View
4 backup_sources/databases/mysql.py
@@ -8,6 +8,6 @@ def __init__(self, db_user, db_pass, db_host):
self.db_pass = db_pass
self.db_host = db_host
- def obtainBackup(self, tmp_path, file_name):
- dbBackupFile = tmp_path + "/" + file_name + ".sql"
+ def obtainBackup(self, dbBackupFile):
os.popen("mysqldump -h " + self.db_host + " --user=\"" + self.db_user + "\" --password=\"" + self.db_pass + "\" --all-databases > " + dbBackupFile)
+ print "mysqldump -h " + self.db_host + " --user=\"" + self.db_user + "\" --password=\"" + self.db_pass + "\" --all-databases > " + dbBackupFile
View
14 sql.py
@@ -3,13 +3,14 @@
import config
-def processSql():
+def processSql(filename):
# First, let's make sure we're actually using the sql database source flag in config
if config.sqlBackup == True:
# Then process each database
for source in config.sqlServers:
sql = createSqlConn(source[0], source[1], source[2], source[3])
- processBackup(sql, config.tmpDir, "test.sql")
+ dbFileName = config.tmpDir + "/" + source[0] + "_" + filename + ".sql"
+ processBackup(sql, dbFileName)
def createSqlConn(backend, db_user, db_pass, db_host):
if backend == "mysql":
@@ -19,8 +20,11 @@ def createSqlConn(backend, db_user, db_pass, db_host):
else:
raise Exception("No valid SQL providers match the source given.")
-def processBackup(sql, tmpDir, dbFileName):
- sql.obtainBackup(tmpDir, dbFileName)
+def processBackup(sql, dbFileName):
+ sql.obtainBackup(dbFileName)
+
+def buildBackupPath(dbFileName):
+ return config.tmpDir + "/" + dbFileName
if __name__ == "__main__":
- processSql()
+ processSql("temp")
Please sign in to comment.
Something went wrong with that request. Please try again.