Skip to content

Commit 6d79ac0

Browse files
committed
use backup subdirectory #21
1 parent cb0a070 commit 6d79ac0

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/main/scala/fr/brouillard/gitbucket/h2/controller/H2BackupController.scala

+5-4
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class H2BackupController extends ControllerBase with AdminAuthenticator {
2727
// private val defaultBackupFile:String = new File(GitBucketHome, "gitbucket-database-backup.zip").toString;
2828

2929
def exportDatabase(exportFile: File): Unit = {
30-
val destFile = if (exportFile.isAbsolute()) exportFile else new File(GitBucketHome, exportFile.toString)
30+
val destFile = if (exportFile.isAbsolute()) exportFile else new File(GitBucketHome+"/backup", exportFile.toString)
3131

3232
val session = Database.getSession(request)
3333
val conn = session.conn
@@ -64,13 +64,14 @@ class H2BackupController extends ControllerBase with AdminAuthenticator {
6464

6565
post("/database/backup", backupForm) { form: BackupForm =>
6666
exportDatabase(new File(form.destFile))
67-
flash += "info" -> "H2 Database has been exported."
67+
val msg:String = "H2 Database has been exported to '"+form.destFile+"'."
68+
flash += "info" -> msg
6869
flash += "dest" -> form.destFile
6970
redirect("/admin/h2backup")
7071
}
7172

7273
private def defaultBackupFileName(): String = {
73-
val format = new java.text.SimpleDateFormat("yyyy-MM-dd-HHmm")
74-
"gitbucket-database-backup-" + format.format(new Date())+ ".zip"
74+
val format = new java.text.SimpleDateFormat("yyyy-MM-dd_HH-mm")
75+
"gitbucket-db-" + format.format(new Date())+ ".zip"
7576
}
7677
}

src/main/twirl/fr/brouillard/gitbucket/h2/export.scala.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
@information(info)
1111
<form action="@path/database/backup" method="POST">
1212
<div class="panel panel-default">
13-
<div class="panel-heading strong">Database backup</div>
13+
<div class="panel-heading strong">H2 Database Backup</div>
1414
<div class="panel-body">
1515
<fieldset>
16-
<label><span class="strong">Database backup file:</span></label>
16+
<label><span class="strong">H2 Database Backup File:</span></label>
1717
<p class="muted">
18-
Allows to export/backup the database content. The same action can be achieved via an HTTP GET call to @path/database/backup
18+
Allows to export/backup the H2 database content. The same action can be achieved via an HTTP GET call to @path/database/backup .
1919
</p>
20-
<input type="text" name="dest" value="@dest" style="width: 400px" />
20+
backup/<input type="text" name="dest" value="@dest" style="width: 400px" />
2121
</fieldset>
2222
</div>
2323
</div>

0 commit comments

Comments
 (0)