Skip to content

Instantly share code, notes, and snippets.

@mbrezu
Created February 12, 2012 12:30
Show Gist options
  • Save mbrezu/1808274 to your computer and use it in GitHub Desktop.
Save mbrezu/1808274 to your computer and use it in GitHub Desktop.
Script pentru backup pe stick
#!/usr/bin/env python
# Script simplu pentru facut copii de rezerva
#
# argument 1: subdirectorul din /media unde facem backup
#
# restul argumentelor: subdirectoare de backup-uit
# Exemplu de desktop entry (cu numele backup.desktop, de plasat in
# ~/Desktop; presupune ca scriptul curent este in ~/bin si ca vrem sa
# arhivam ~/Documents si ~/work)
# [Desktop Entry]
# Version=1.0
# Name=Backup!
# GenericName=Backup
# Comment=Copie de rezerva pe stick
# Terminal=true
# Exec=/home/miron/bin/backup.py truecrypt1 /home/miron/Documents /home/miron/work
# Type=Application
# Icon=python
# Categories=Utilities
# MimeType=text/plain;
import sys
import os.path
import datetime
import os
def tasta_finish():
print "Apasa o tasta..."
raw_input()
sys.exit(0)
print sys.argv[2:]
destdir = "/media/" + sys.argv[1]
if not os.path.isdir(destdir):
print "Introduce stick-ul si incearca din nou"
tasta_finish()
file_name = os.path.join(destdir,
"Backup-din-" + datetime.datetime.now().strftime("%y-%m-%d") + ".zip")
quoted_args = ["'" + arg + "'" for arg in sys.argv[2:]]
cmd = "zip -9r '" + file_name + "' " + " ".join(quoted_args)
print cmd
os.system(cmd)
os.system("sync")
os.system("sync")
os.system("sync")
tasta_finish()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment