Browse Source

Remove backup stuff and move to its own branch (backup)

sbkwgh 8 years ago
parent
commit
3d5091d59d

+ 18 - 4
frontend/src/components/routes/Admin.vue

@@ -31,10 +31,24 @@
 			return {
 				selected: null,
 				routes: [
-					{ title: 'Dashboard', route: 'dashboard', description: 'Quick links and stats about your forum', icon: 'fa-home' },
-					{ title: 'General', route: 'general', description: 'Admin accounts, categories and settings', icon: 'fa-th' },
-					{ title: 'Moderation', route: 'moderation/reports', description: 'View and respond to user reports', icon: 'fa-exclamation-circle' },
-					{ title: 'Back-up', route: 'backup', description: 'Download and restore forum data', icon: 'fa-cloud-download' }
+					{
+						title: 'Dashboard',
+						route: 'dashboard',
+						description: 'Quick links and stats about your forum',
+						icon: 'fa-home' 
+					},
+					{
+						title: 'General',
+						route: 'general',
+						description: 'Admin accounts, categories and settings',
+						icon: 'fa-th'
+					},
+					{
+						title: 'Moderation',
+						route: 'moderation/reports',
+						description: 'View and respond to user reports',
+						icon: 'fa-exclamation-circle'
+					},
 				]
 			}
 		},

+ 0 - 114
frontend/src/components/routes/AdminBackup.vue

@@ -1,114 +0,0 @@
-<template>
-	<div class='admin_backup'>
-		<confirm-modal v-model='showDeleteModal' color='red' text='Delete backup'>
-			Are you sure you want to delete this backup?
-		</confirm-modal>
-
-		<confirm-modal v-model='showRestoreModal' text='Restore backup'>
-			The uploaded file does not match any previous backups - unless this backup is from
-			a different forum instance, it is likely corrupted. <br/><br/>
-			If the file is corrupted the backup restore will fail. Continue?
-		</confirm-modal>		
-
-		<h1 class='admin_backup__title'>Backup</h1>	
-
-		<div class='category_widget__box'>
-			<div class='category_widget__text'>
-				<div class='admin_backup__header'>
-					<div class='category_widget__text__title'>Previous backups</div>
-					<div>
-						<button class='button button--blue'>Backup now</button>
-						<button class='button' @click='showRestoreModal = true'>Restore local backup</button>
-
-					</div>
-				</div>
-				Listed below are previous backups and date created
-			</div>
-			<table>
-				<tr>
-					<th>Date created</th>
-					<th>Size</th>
-					<th>SHA-256 hash</th>
-					<th>Actions</th>
-				</tr>
-				<tr>
-					<td>{{new Date() | formatDate }}</td>
-					<td>895 kb</td>
-					<td>16cedf80ade01c62bdd1ae931d0492330c0b62bf294c08c095ce2fab21a9298d</td>
-					<td>
-						<button class='button button--thin_text'>Restore</button>
-						<menu-button
-							:options='[
-								{ value: "Download" },
-								{ value: "Delete", event: "delete-backup" }
-							]'
-
-							@delete-backup='showDeleteModal = true'
-						>
-							<button class='button button--borderless button--thin_text'>More options</button>
-						</menu-button>
-					</td>
-				</tr>
-			</table>
-		</div>
-	</div>
-</template>
-
-<script>
-	import MenuButton from '../MenuButton'
-	import ConfirmModal from '../ConfirmModal'
-
-	export default {
-		name: 'AdminBackup',
-		components: {
-			MenuButton,
-			ConfirmModal
-		},
-		data () {
-			return {
-				showDeleteModal: false,
-				showRestoreModal: false
-			}
-		}
-	}
-</script>
-
-<style lang='scss' scoped>
-	@import '../../assets/scss/variables.scss';
-
-	.admin_backup {
-		padding: 1rem 2rem;
-
-		@at-root #{&}__title {
-			margin: 0.5rem 0 1rem 0;
-		}
-		@at-root #{&}__header {
-			display: flex;
-			align-items: baseline;
-			justify-content: space-between;
-
-			button:first-child {
-				margin-right: 0.5rem;
-			}
-		}
-
-		table {
-			width: 100%;
-			border-collapse: collapse;
-
-			th, td {
-				text-align: left;
-				padding: 0.5rem;
-			}
-
-			tr {
-				border-bottom: thin solid $color__lightgray--primary;
-			}
-
-			.menu_button {
-				display: inline-block;
-				margin-left: 0.5rem;
-			}
-		}
-	}
-</style>

+ 1 - 3
frontend/src/main.js

@@ -31,7 +31,6 @@ const AdminDashboard = () => import('./components/routes/AdminDashboard')
 const AdminModerationReports = () => import('./components/routes/AdminModerationReports')
 const AdminModerationBannedUsers = () => import('./components/routes/AdminModerationBannedUsers')
 const AdminGeneral = () => import('./components/routes/AdminGeneral')
-const AdminBackup = () => import('./components/routes/AdminBackup')
 
 import NotFound from './components/routes/NotFound'
 
@@ -62,8 +61,7 @@ const router = new VueRouter({
 			{ path: 'general', component: AdminGeneral },
 			{ path: 'moderation', redirect: '/admin/moderation/reports' },
 			{ path: 'moderation/reports', component: AdminModerationReports },
-			{ path: 'moderation/bans', component: AdminModerationBannedUsers },
-			{ path: 'backup', component: AdminBackup }
+			{ path: 'moderation/bans', component: AdminModerationBannedUsers }
 		] },
 		{ path: '*', component: NotFound }
 	],

+ 0 - 44
routes/backup.js

@@ -1,44 +0,0 @@
-let express = require('express')
-let router = express.Router()
-
-let randomBytes = require('crypto').randomBytes
-let exec = require('child_process').exec
-let fs = require('fs')
-
-let { Sequelize, Backup } = require('../models')
-const Errors = require('../lib/errors')
-const Config = require('../config/config.json')
-
-function promiseFromChildProcess(child) {
-	return new Promise((resolve, reject) => {
-		child.addListener('error', reject)
-		child.addListener('exit', resolve)
-	})
-}
-
-
-router.post('/', async (req, res) => {
-	try {
-		let dev = Config.development
-		let id = randomBytes(12).toString('base64')
-		let backupName = id + '-' + (new Date()).toISOString() + '.sql'
-
-		let sha256 = await promiseFromChildProcess(exec(`
-				mkdir ../backups -p
-				&& mysqldump --lock-all-tables -u ${dev.username} -p${dev.password} ${dev.database} > ../backups/${backupName}
-				&& openssl dgst -sha256 ../backups/${backupName}
-		`))
-		let size = fs.statsSync('../backups/' + backupName).size
-		let backup = await Backup.create({ sha256, size })
-
-		res.json(backup.toJSON())
-	} catch (e) {
-		console.log(e)
-		res.status(500)
-		res.json({
-			errors: [Errors.unknown]
-		})
-	}
-})
-
-module.exports = router

+ 0 - 1
server.js

@@ -46,7 +46,6 @@ app.use('/api/v1/ban', require('./routes/ban'))
 app.use('/api/v1/search', require('./routes/search'))
 app.use('/api/v1/log', require('./routes/log'))
 app.use('/api/v1/poll', require('./routes/poll'))
-app.use('/api/v1/backup', require('./routes/backup'))
 
 app.use('/static', express.static(path.join(__dirname, 'frontend', 'dist', 'static')))
 app.get('*', (req, res) => {