forked from sunbenxin/oscm
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Neo Chen
committed
May 29, 2014
1 parent
efe4111
commit 8e5a7aa
Showing
6 changed files
with
462 additions
and
383 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,38 @@ | ||
*.py[cod] | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Packages | ||
*.egg | ||
*.egg-info | ||
dist | ||
build | ||
eggs | ||
parts | ||
#bin | ||
var | ||
sdist | ||
develop-eggs | ||
.installed.cfg | ||
lib | ||
lib64 | ||
__pycache__ | ||
|
||
# Installer logs | ||
pip-log.txt | ||
|
||
# Unit test / coverage reports | ||
.coverage | ||
.tox | ||
nosetests.xml | ||
|
||
# Translations | ||
*.mo | ||
|
||
# Mr Developer | ||
.mr.developer.cfg | ||
.project | ||
.pydevproject | ||
/shell/*.bak | ||
MANIFEST | ||
*.py[cod] | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Packages | ||
*.egg | ||
*.egg-info | ||
dist | ||
build | ||
eggs | ||
parts | ||
#bin | ||
var | ||
sdist | ||
develop-eggs | ||
.installed.cfg | ||
lib | ||
lib64 | ||
__pycache__ | ||
|
||
# Installer logs | ||
pip-log.txt | ||
|
||
# Unit test / coverage reports | ||
.coverage | ||
.tox | ||
nosetests.xml | ||
|
||
# Translations | ||
*.mo | ||
|
||
# Mr Developer | ||
.mr.developer.cfg | ||
.project | ||
.pydevproject | ||
/shell/*.bak | ||
MANIFEST |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#!/usr/bin/python3 | ||
|
||
#-*- coding: utf-8 -*- | ||
############################################## | ||
# Home : http://netkiller.github.io | ||
# Author: Neo <[email protected]> | ||
############################################## | ||
|
||
#basedir=os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | ||
|
||
try: | ||
#sys.path.append(basedir + '/lib/python3.3/site-packages') | ||
import os,io,sys,subprocess | ||
import logging, configparser | ||
import threading | ||
from optparse import OptionParser, OptionGroup | ||
import time | ||
from datetime import datetime | ||
import getpass | ||
except ImportError as err: | ||
print("Error: %s" %(err)) | ||
|
||
workspace=os.path.expanduser('~/workspace') | ||
config = None | ||
inifile = workspace+'/'+'git.ini' | ||
|
||
try: | ||
if not os.path.exists(inifile): | ||
raise Exception('Cannot open file', inifile) | ||
config = configparser.SafeConfigParser() | ||
config.read(inifile) | ||
|
||
except configparser.NoSectionError as err: | ||
print("Error: %s %s" %(err, inifile)) | ||
sys.exit(1) | ||
except Exception as err: | ||
print("Error: %s %s" %(err, inifile)) | ||
sys.exit(1) | ||
conf = {} | ||
|
||
if not os.path.isdir(workspace): | ||
os.makedirs(workspace) | ||
os.chdir(workspace) | ||
for sect in config.sections(): | ||
print('===== '+sect+' =====') | ||
conf = dict(config.items(sect)) | ||
source = conf['origin'].split(':')[1] | ||
#print(source) | ||
if not os.path.isdir(source): | ||
if not os.path.isdir(source+'/.git'): | ||
cmd = 'git clone ' + conf['origin'] +' '+ source; | ||
os.system(cmd) | ||
#print(cmd) | ||
if os.path.isdir(source) : | ||
os.chdir(source) | ||
for remote in conf['remote'].split(',') : | ||
cmd = 'git remote add ' + remote | ||
os.system(cmd) | ||
#print(remote) | ||
#print(cmd) | ||
os.chdir(workspace) | ||
else: | ||
os.chdir(source) | ||
os.system('git reset --hard') | ||
os.system('git pull origin') | ||
|
||
cmd = 'git remote' | ||
remote = subprocess.getoutput(cmd) | ||
for current in remote.split("\n"): | ||
if current != 'origin': | ||
print('----- '+current+' -----') | ||
push = 'git push '+current+ ' master' | ||
os.system(push) | ||
os.chdir(workspace) | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,93 +1,93 @@ | ||
backup | ||
====== | ||
|
||
Backup Software | ||
|
||
Help | ||
------ | ||
$ ./backup --help | ||
Usage: backup [options] arg1 arg2 <task> | ||
|
||
Options: | ||
-h, --help show this help message and exit | ||
-f FILE, --file=FILE write report to FILE | ||
-q, --quiet don't print status messages to stdout | ||
--config=CONFIG Read configuration options from file. | ||
--task=TASK task config file. | ||
--schedule=SCHEDULE schedule config file. | ||
-v, --version print version number | ||
-d, --daemon run as daemon | ||
--logfile=LOGFILE logs file. | ||
|
||
arg1: | ||
arg1: task | schedule | ||
|
||
arg2: | ||
arg2: list | run | ||
|
||
Debug Options: | ||
--debug Print debug information | ||
|
||
New Task | ||
------ | ||
[www] | ||
policy=mirror | ||
from=/www/www.example.com/* | ||
to=/tmp/www | ||
exclude=.svn | ||
include=* | ||
|
||
[database] | ||
policy=mysql | ||
host=192.168.2.1 | ||
port=3306 | ||
user=www | ||
password=123456 | ||
database=test | ||
compress=gzip | ||
to=/tmp | ||
|
||
Run Task | ||
------ | ||
|
||
$ ./backup task list | ||
www | ||
htdocs | ||
database | ||
|
||
|
||
New Schedule | ||
------ | ||
|
||
$ ./backup schedule show weekly | ||
www: True | ||
images: False | ||
|
||
$ ./backup schedule show monthly | ||
test: True | ||
test1: True | ||
test2: True | ||
|
||
|
||
Run Schedule | ||
------ | ||
|
||
$ backup schedule list | ||
hourly | ||
daily | ||
weekly | ||
monthly | ||
|
||
|
||
Crontab Schedule | ||
------ | ||
|
||
# m h dom mon dow command | ||
17 * * * * test -x /srv/sbin/backup || ( backup schedule run hourly ) | ||
25 6 * * * test -x /srv/sbin/backup || ( backup schedule run daily ) | ||
47 6 * * 7 test -x /srv/sbin/backup || ( backup schedule run weekly ) | ||
52 6 1 * * test -x /srv/sbin/backup || ( backup schedule run monthly ) | ||
|
||
|
||
*/30 * * * * /srv/sbin/backup task run www | ||
|
||
backup | ||
====== | ||
|
||
Backup Software | ||
|
||
Help | ||
------ | ||
$ ./backup --help | ||
Usage: backup [options] arg1 arg2 <task> | ||
|
||
Options: | ||
-h, --help show this help message and exit | ||
-f FILE, --file=FILE write report to FILE | ||
-q, --quiet don't print status messages to stdout | ||
--config=CONFIG Read configuration options from file. | ||
--task=TASK task config file. | ||
--schedule=SCHEDULE schedule config file. | ||
-v, --version print version number | ||
-d, --daemon run as daemon | ||
--logfile=LOGFILE logs file. | ||
|
||
arg1: | ||
arg1: task | schedule | ||
|
||
arg2: | ||
arg2: list | run | ||
|
||
Debug Options: | ||
--debug Print debug information | ||
|
||
New Task | ||
------ | ||
[www] | ||
policy=mirror | ||
from=/www/www.example.com/* | ||
to=/tmp/www | ||
exclude=.svn | ||
include=* | ||
|
||
[database] | ||
policy=mysql | ||
host=192.168.2.1 | ||
port=3306 | ||
user=www | ||
password=123456 | ||
database=test | ||
compress=gzip | ||
to=/tmp | ||
|
||
Run Task | ||
------ | ||
|
||
$ ./backup task list | ||
www | ||
htdocs | ||
database | ||
|
||
|
||
New Schedule | ||
------ | ||
|
||
$ ./backup schedule show weekly | ||
www: True | ||
images: False | ||
|
||
$ ./backup schedule show monthly | ||
test: True | ||
test1: True | ||
test2: True | ||
|
||
|
||
Run Schedule | ||
------ | ||
|
||
$ backup schedule list | ||
hourly | ||
daily | ||
weekly | ||
monthly | ||
|
||
|
||
Crontab Schedule | ||
------ | ||
|
||
# m h dom mon dow command | ||
17 * * * * test -x /srv/sbin/backup || ( backup schedule run hourly ) | ||
25 6 * * * test -x /srv/sbin/backup || ( backup schedule run daily ) | ||
47 6 * * 7 test -x /srv/sbin/backup || ( backup schedule run weekly ) | ||
52 6 1 * * test -x /srv/sbin/backup || ( backup schedule run monthly ) | ||
|
||
|
||
*/30 * * * * /srv/sbin/backup task run www | ||
|
Oops, something went wrong.