-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfabfile.py
49 lines (38 loc) · 987 Bytes
/
fabfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#
# Fabric script to deploy website
#
#
# examples
# ~$ fab deploy
import os
from time import strftime
from fabric.api import env, run, local, cd
env.user = "verese"
env.hosts = ["verese.net:2222"]
env.backup_dir = "/home/verese/backup/verese.net"
env.remote_app_dir = "/home/verese/public_html/"
def update_code():
"""
Push code to server
Update server instance
"""
local("git pull origin master")
local("git push origin master")
with cd(env.remote_app_dir):
run("git pull origin master")
def backup():
"""
Backup
"""
date = strftime("%Y%m%d%H%M")
with cd(os.path.join(env.remote_app_dir, '..')):
run("tar czf %s/verese-%s.tar.gz public_html" %
(env.backup_dir, date)
)
def deploy(do_update_code=True, do_backup=False):
if do_update_code == True:
update_code()
if do_backup == True:
backup()
with cd(env.remote_app_dir):
run("git pull origin master")