[sysadmin-bin] Create backup dumps read-only



commit 4f7c6a676881ad46633675c30de8c86735a8796e
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Mon Jan 14 10:26:18 2013 -0500

    Create backup dumps read-only
    
    When backing up a database as a dump, create the target file read-only

 copy-db.py |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
---
diff --git a/copy-db.py b/copy-db.py
index 83a36d5..00b7622 100755
--- a/copy-db.py
+++ b/copy-db.py
@@ -164,7 +164,8 @@ for db in dbs:
             sys.stderr.write("ERROR: '%s' is not writable\n" % backup_dir)
             sys.exit(1)
 
-        outfile = open(outfilename_tmp, "w")
+        outfile_fd = os.open(outfilename_tmp, os.O_WRONLY | os.O_CREAT, int('0600', 8))
+        outfile = os.fdopen(outfile_fd, 'w')
         dump = subprocess.Popen(['mysqldump',
                                  '--single-transaction',
                                  '--default-character-set=utf8',



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]