Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Support multiple repositories #131

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ js/node_modules
logs
repo
borgweb/_version.py
borg-env
.eggs
39 changes: 35 additions & 4 deletions borgweb/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ class Config(object):
"""This is the basic configuration class for BorgWeb."""

#: builtin web server configuration
HOST = '127.0.0.1' # use 0.0.0.0 to bind to all interfaces
HOST = '0.0.0.0' # use 0.0.0.0 to bind to all interfaces
PORT = 5000 # ports < 1024 need root
DEBUG = False # if True, enable reloader and debugger

#: borg / borgweb configuration
LOG_DIR = 'logs'
REPOSITORY = 'repo'
LOG_DIR = '/var/www/logs/'
REPOSITORY = '/var/www/repo'
NAME = 'localhost'
BORG_LOGGING_CONF = "/var/www/borgWebDan/logging.conf"
TO_BACKUP = "/var/www/borgWebDan"

# when you click on "start backup", this command will be given to a OS
# shell to execute it.
Expand All @@ -21,5 +23,34 @@ class Config(object):
# configure it in an appropriate and secure way).
# template placeholders like {LOG_DIR} (and other stuff set in the config)
# will be expanded to their value before the shell command is executed.
BACKUP_CMD = "BORG_LOGGING_CONF=logging.conf borg create --list --stats --show-version --show-rc {REPOSITORY}::{NAME}-{LOCALTIME} /etc >{LOG_DIR}/{NAME}-{LOCALTIME} 2>&1 </dev/null"
BACKUP_CMD = "BORG_LOGGING_CONF={BORG_LOGGING_CONF} borg create --list --stats --show-version --show-rc {REPOSITORY}::{NAME}-{LOCALTIME} {TO_BACKUP} >{LOG_DIR}/test/{NAME}-{LOCALTIME} 2>&1 </dev/null"

BACKUP_REPOS = {
"test": {
"repo_path": "/root/repo",
"log_path": "{LOG_DIR} /test/",
"backups": [
{
"name": "testaewraserfsdf",
"script": "script",
},
{
"name": "test1",
"script": "script",
}
]
},
"test1": {
"repo_path": "/root/repo",
"backups": [
{
"name": "test",
"script": "script",
},
{
"name": "test1",
"script": "script",
}
]
}
}
126 changes: 102 additions & 24 deletions borgweb/static/bundle.js

Large diffs are not rendered by default.

141 changes: 135 additions & 6 deletions borgweb/static/style.css
Original file line number Diff line number Diff line change
@@ -1,37 +1,164 @@
html { height: 100%; }
body {
padding-top: 66px;

#wrapper {
padding-left: 0;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
}

#wrapper.toggled {
padding-left: 250px;
}

#sidebar-wrapper {
z-index: 1000;
position: fixed;
left: 250px;
width: 0;
height: 100%;
margin-left: -250px;
overflow-y: auto;
background: linear-gradient(to bottom,#3c3c3c 0,#222 100%);
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
}

#wrapper.toggled #sidebar-wrapper {
width: 250px;
}

#page-content-wrapper {
width: 100%;
position: absolute;
padding: 15px;
}

#page-content {
/* padding-top: 66px; */
}

#wrapper.toggled #page-content-wrapper {
position: absolute;
margin-right: -250px;
}


/* Sidebar Styles */

.sidebar-nav {
position: absolute;
top: 0;
width: 250px;
margin: 0;
padding: 0;
list-style: none;
}

.sidebar-nav li {
text-indent: 20px;
line-height: 40px;
}

.sidebar-nav li a {
display: block;
text-decoration: none;
color: #fff;
}

.sidebar-nav li a:hover {
text-decoration: none;
color: #fff;
background: rgba(255, 255, 255, 0.2);
}

.sidebar-nav li a:active, .sidebar-nav li a:focus {
text-decoration: none;
}

.sidebar-nav>.sidebar-brand {
height: 65px;
font-size: 18px;
line-height: 60px;
}

.sidebar-nav>.sidebar-brand a {
color: #FFF;
}

.sidebar-nav>.sidebar-brand a:hover {
color: #fff;
background: none;
}

@media(min-width:768px) {
#wrapper {
padding-left: 0;
}
#wrapper.toggled {
padding-left: 250px;
}
#sidebar-wrapper {
width: 0;
}
#wrapper.toggled #sidebar-wrapper {
width: 250px;
}
#page-content-wrapper {
padding: 20px;
position: relative;
}
#wrapper.toggled #page-content-wrapper {
position: relative;
margin-right: 0;
}
}

.borg-green {
color: #00dd00
}

#no-logs-error {
display: none;
}

#content-row {
height: calc(95vh - 140px);
margin-bottom: 8px;
}

#log-viewer,
#list-viewer {
height: 100%;
height: calc(95vh - 140px);
}


#log-viewer pre {
height: 100%;
overflow-y: hidden;
}

#list-viewer {
.list-viewer {
height: 100%;
overflow-y: scroll;
overflow-y: auto;
padding: 4px 0 0;
margin-left: 10px;
border: 1px solid #ccc;
border-left: 0;
}
#list-viewer li {

.list-viewer li {
border: 1px solid #ccc;
border-right: 0;
border-radius: 4px;
border-top-right-radius: 0;
border-bottom-right-radius: 0;
cursor: pointer;
}

.list-status-indicator {
font-size: 18px;
color: #ccc;
Expand Down Expand Up @@ -77,11 +204,13 @@ a.shown-log {
}

#log-text {
min-height: 100%;
height: 100%;
color: black;
white-space: pre-wrap;
line-height: 18px;
}

#log-text mark {
width: calc(100% + 19px);
display: inline-block;
Expand Down
17 changes: 8 additions & 9 deletions borgweb/templates/_layout.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<!doctype html>
<html lang="en">
<head>
<title>{{ title }}</title>
<title>BorgWeb</title>

<meta charset="UTF-8">
<link rel="icon" href="{{ url_for('static', filename='favicon.ico') }}" type="image/x-icon" />
<meta name="description" content="`borgweb` is a web frontend for the `borgbackup` software.">
<meta name="author" content="https://github.com/borgbackup/borgweb/blob/master/AUTHORS">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<link href="{{ url_for('static', filename='bootstrap/bootstrap.min.css') }}" rel="stylesheet">
<link href="{{ url_for('static', filename='bootstrap/bootstrap-theme.min.css') }}" rel="stylesheet">
<link href="{{ url_for('static', filename='style.css') }}" rel="stylesheet">
Expand All @@ -20,13 +20,12 @@
</style>
</head>
<body>
<div id="container" class="container">

<div id="wrapper" class="toggled">
{% include '_nav.html' %}

{% block content %}{% endblock %}
</div><!-- /container -->
</div>

</body>
</html>

81 changes: 43 additions & 38 deletions borgweb/templates/_nav.html
Original file line number Diff line number Diff line change
@@ -1,38 +1,43 @@
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<ul class="nav navbar-nav" style="margin-top: 0; margin-bottom: 0;">
<li>
<a class="navbar-brand" style="color: white;" href="/">BorgWeb</a>
</li>
<li>
<button type="submit" class="btn btn-success navbar-brand i18n" style="margin-left: 8px; color: white; padding: 1px 12px 2px 14px; height: 40px; margin-top: 5px;" onClick="window.startBackup()" title="Start a backup"><span class="glyphicon glyphicon-play" aria-hidden="true"></span> <x-i18n>Start Backup</x-i18n></button>
</li>
</ul>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<!-- dummy:
<li>
<a href="/status/"><i class="fa fa-list fa-fw"></i> Status</a>
</li>
-->
<li>
<a href="https://borgweb.readthedocs.io/"
class="navbar-link i18n" title="Open docs in new window" target="_blank"><span class="glyphicon glyphicon-question-sign" aria-hidden="true"></span> <x-i18n>Documentation</x-i18n></a>
</li>
</ul>
<ul class="nav navbar-nav pull-right">
<li>
<a href="https://github.com/borgbackup/borgweb"
class="navbar-link i18n" title="See source code on Github" target="_blank">Github</a>
</li>
</ul>
</div>
</div>
</div>
<!-- Sidebar -->
<div id="sidebar-wrapper">
<ul class="sidebar-nav">
<li class="sidebar-brand">
<a href="#">
<span class="borg-green">Borg</span>Web
</a>
</li>
<li>
<a href="#"
onclick="window.viewBackups()">
<span class="glyphicon glyphicon-tasks" aria-hidden="true"></span>
Backups
</a>
</li>
<li>
<a href="#"
onclick="window.viewRepositories()">
<span class="glyphicon glyphicon-hdd" aria-hidden="true"></span>
Repositories
</a>
</li>
<li>
<a href="https://borgweb.readthedocs.io/"
class="navbar-link i18n"
title="Open docs in new window"
target="_blank">
<span class="glyphicon glyphicon-question-sign" aria-hidden="true"></span>
<x-i18n>Documentation</x-i18n>
</a>
</li>
<li>
<a href="https://github.com/borgbackup/borgweb"
class="navbar-link i18n"
title="See source code on Github"
target="_blank">
<span class="glyphicon glyphicon-wrench"></span>
Github
</a>
</li>
</ul>
</div>
<!-- /#sidebar-wrapper -->
Loading