-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCase4.py
28 lines (26 loc) · 1.37 KB
/
Case4.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
"""Prints information about an FMI observation station to the screen.
Description:
1. Download archive choosed from remote server
2. Restore the wordpress database
3. Link database to wordpress
Author:
@npltr62 - 01.03.2022
"""
import fnct #call functions
import env #call variables
import logging #call logging module
package= fnct.distrib() #detect witch installing package should be used
cmd1= f'sudo {package} install lftp -y'
cmd2=f'lftp sftp://{env.user}:{env.pwd}@{env.host} -e "get ~/backup/{env.datestr}_backup.tar.gz ; quit" && sudo tar -xf {env.datestr}_backup.tar.gz -C /var/www/html --strip-components=3 && sudo rm {env.datestr}_backup.tar.gz'
cmd3=f'sudo mysql -u root wordpress < /var/www/html/{env.datestr}_dump.sql && sudo rm -f /var/www/html/{env.datestr}_dump.sql'
cmd4='sudo chown -R www-data:www-data /var/www/html/wordpress/'
fnct.run(cmd1) #install ltfp package
logging.info(f'start download {env.datestr}_backup.tar.gz from ftp server')
print(f'start download {env.datestr}_backup.tar.gz from ftp server')
fnct.run(cmd2) #download archive from ftp server and extract it in html directory
logging.info('start restore dump')
print(('start restore dump'))
fnct.run(cmd3) #run sql instructions in order to restore wordpress database
logging.info('change right access')
print('change right access')
fnct.run(cmd4) #change the owner of wordpress folder recursively