-
Notifications
You must be signed in to change notification settings - Fork 2
/
fabfile.py
36 lines (26 loc) · 1012 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
#!/usr/bin/env
from fabric.api import *
# Environments
def dev():
env.hosts = ['[email protected]:2222']
env.key_filename = '~/.vagrant.d/insecure_private_key'
def prod():
env.hosts = ['[email protected]:22']
# Deployment
def reload():
sudo('localwiki-manage collectstatic --noinput')
def deploy():
put('themes', '/usr/share/localwiki', use_sudo=True)
sudo('localwiki-manage collectstatic --noinput')
sudo('service apache2 restart')
# Backups
def backup_db(filename):
sudo('pg_dump -U postgres localwiki > /tmp/.localwiki_backup.sql', user='postgres')
get('/tmp/.localwiki_backup.sql', filename)
sudo('rm /tmp/.localwiki_backup.sql')
def restore_db(filename):
put(filename, '/tmp/.localwiki_backup.sql')
sudo('psql -c "DROP DATABASE localwiki"', user='postgres')
sudo('createdb -T template_postgis localwiki', user='postgres')
sudo('psql localwiki < /tmp/.localwiki_backup.sql', user='postgres')
run('rm /tmp/.localwiki_backup.sql')