add downloadable backup

This commit is contained in:
frederik
2024-11-10 18:17:11 +01:00
committed by Nachtzuster
parent ef86658b6b
commit cb8abd4f22
2 changed files with 23 additions and 1 deletions
+22
View File
@@ -0,0 +1,22 @@
<?php
define('__ROOT__', dirname(dirname(__FILE__)));
require_once(__ROOT__.'/scripts/common.php');
$user = get_user();
$home = get_home();
ensure_authenticated('You must be authenticated to download backup files.');
set_timezone();
$date = new DateTime();
$date_str = $date->format("Ymd\\THis");
header("Content-Description: File Transfer");
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"backup-$date_str.tar\"");
$err=null;
set_time_limit(0);
passthru("sudo -u $user $home/BirdNET-Pi/scripts/backup_data.sh -a backup -f -", $err);
debug_log(strval($err));
exit();
+1 -1
View File
@@ -49,7 +49,7 @@ function update() {
<button type="submit" name="submit" value="sudo clear_all_data.sh" onclick="return confirm('Clear ALL Data? Note that this cannot be undone and will take up to 90 seconds.')">Clear ALL data</button> <button type="submit" name="submit" value="sudo clear_all_data.sh" onclick="return confirm('Clear ALL Data? Note that this cannot be undone and will take up to 90 seconds.')">Clear ALL data</button>
</div> </div>
</form> </form>
</div> <div><a href="scripts/backup.php" download ><button onclick="return confirm('Download backup? Note that this could take a long time.')">Download backup</button></a></div>
<?php <?php
$cmd="cd ".$home."/BirdNET-Pi && sudo -u ".$user." git rev-list --max-count=1 HEAD"; $cmd="cd ".$home."/BirdNET-Pi && sudo -u ".$user." git rev-list --max-count=1 HEAD";
$curr_hash = shell_exec($cmd); $curr_hash = shell_exec($cmd);