Add scheduled database backups

This commit is contained in:
JonnyWong16 2016-02-17 18:41:55 -08:00
parent 3926d97fc6
commit 85b3f081bf
4 changed files with 31 additions and 29 deletions

View file

@ -13,7 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with PlexPy. If not, see <http://www.gnu.org/licenses/>.
from plexpy import logger, notifiers, plextv, pmsconnect, common, log_reader, datafactory, graphs, users, libraries
from plexpy import logger, notifiers, plextv, pmsconnect, common, log_reader, datafactory, graphs, users, libraries, database
from plexpy.helpers import checked, addtoapi, get_ip, create_https_certificates
from mako.lookup import TemplateLookup
@ -1339,6 +1339,21 @@ class WebInterface(object):
def get_scheduler_table(self, **kwargs):
return serve_template(templatename="scheduler_table.html")
@cherrypy.expose
@addtoapi()
def backup_db(self):
""" Creates a manual backup of the plexpy.db file """
result = database.make_backup(scheduler=False)
if result:
cherrypy.response.headers['Content-type'] = 'application/json'
return json.dumps({'message': 'Database backup successful.'})
else:
cherrypy.response.headers['Content-type'] = 'application/json'
return json.dumps({'message': 'Database backup failed.'})
@cherrypy.expose
def get_notification_agent_config(self, agent_id, **kwargs):
if agent_id.isdigit():