projects
/
sitarba.git
/ commitdiff
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
dc452a7
)
ask before making backup
author
Stefan Huber <shuber2@gmx.at>
Mon, 14 May 2012 09:20:08 +0000
(11:20 +0200)
committer
Stefan Huber <shuber2@gmx.at>
Mon, 14 May 2012 09:20:08 +0000
(11:20 +0200)
shbackup
patch
|
blob
|
history
diff --git
a/shbackup
b/shbackup
index 351aef95d877e3f0d095289ab582e7619ef21811..17bd3318208b8ce01e6363c68a628e15a80a55a7 100755
(executable)
--- a/
shbackup
+++ b/
shbackup
@@
-305,23
+305,29
@@
class BackupManager:
if mode != "full":
print("** Warning: full backup recommended!")
if mode != "full":
print("** Warning: full backup recommended!")
- # Create new target directory
- basedir = self.conf.directory
- dirname = Backup.getDirName(now, epoch, mode)
- tmpdirname = dirname + ("-%x" % (random.random()*2e16) )
- targetdir = os.path.join(basedir, tmpdirname)
- os.mkdir( targetdir )
# If we have a full backup, we backup everything
since = None
# If we have a full backup, we backup everything
since = None
-
- # Get latest full backup time
if mode == "diff":
since = sorted(oldfullbackups, key=lambda b: b.date)[-1].date
if mode == "diff":
since = sorted(oldfullbackups, key=lambda b: b.date)[-1].date
- # Get latest backup time
elif mode == "incr":
since = sorted(oldbackups, key=lambda b: b.date)[-1].date
elif mode == "incr":
since = sorted(oldbackups, key=lambda b: b.date)[-1].date
+ if since != None:
+ print("Making backup relative to ", since.ctime())
+
+ yesno = self.ask_user_yesno("Proceed? [Y, n] ")
+ if yesno == "n":
+ return
+
+ # Create new target directory
+ basedir = self.conf.directory
+ dirname = Backup.getDirName(now, epoch, mode)
+ tmpdirname = dirname + ("-%x" % (random.random()*2e16) )
+ targetdir = os.path.join(basedir, tmpdirname)
+ os.mkdir( targetdir )
+
+
# Backup all file sets
for s in self.conf.sets:
self.backupFileSet(s, targetdir, since)
# Backup all file sets
for s in self.conf.sets:
self.backupFileSet(s, targetdir, since)
@@
-375,7
+381,7
@@
class BackupManager:
return
basedir = self.conf.directory
return
basedir = self.conf.directory
- yesno = self.ask_user_yesno("Remove entries marked by '*'?")
+ yesno = self.ask_user_yesno("Remove entries marked by '*'?
[y, N]
")
if yesno == "y":
for d in removeDirs:
shutil.rmtree(os.path.join(basedir, d))
if yesno == "y":
for d in removeDirs:
shutil.rmtree(os.path.join(basedir, d))
@@
-385,7
+391,7
@@
class BackupManager:
print(question + " y")
return "y"
else:
print(question + " y")
return "y"
else:
- return input(question
+ " [y, N] "
)
+ return input(question)
def printUsage():
def printUsage():