Use the (often much faster) zip format by default for backups.
This commit is contained in:
parent
3cc47bc803
commit
145475bd75
|
@ -36,7 +36,10 @@ tmp/cache/*---*
|
|||
# Docker files
|
||||
/docker-compose.yml
|
||||
/docker-compose.override.yml
|
||||
|
||||
# Backups
|
||||
/*.tar.gz
|
||||
/*.zip
|
||||
|
||||
# Plugins
|
||||
/plugins/*
|
||||
|
|
|
@ -24,6 +24,7 @@ services:
|
|||
- tmp_data:/var/azuracast/www_tmp
|
||||
- station_data:/var/azuracast/stations
|
||||
- shoutcast2_install:/var/azuracast/servers/shoutcast2
|
||||
- backups:/var/azuracast/backups
|
||||
restart: always
|
||||
logging: &default-logging
|
||||
options:
|
||||
|
@ -120,3 +121,4 @@ volumes:
|
|||
station_data: {}
|
||||
shoutcast2_install: {}
|
||||
tmp_data: {}
|
||||
backups: {}
|
||||
|
|
|
@ -33,6 +33,7 @@ services:
|
|||
- tmp_data:/var/azuracast/www_tmp
|
||||
- station_data:/var/azuracast/stations
|
||||
- shoutcast2_install:/var/azuracast/servers/shoutcast2
|
||||
- backups:/var/azuracast/backups
|
||||
restart: always
|
||||
logging: &default-logging
|
||||
options:
|
||||
|
@ -112,3 +113,4 @@ volumes:
|
|||
station_data: {}
|
||||
tmp_data: {}
|
||||
www_data: {}
|
||||
backups: {}
|
||||
|
|
|
@ -174,7 +174,7 @@ bash() {
|
|||
#
|
||||
# Back up the Docker volumes to a .tar.gz file.
|
||||
# Usage:
|
||||
# ./docker.sh backup [/custom/backup/dir/custombackupname.tar.gz]
|
||||
# ./docker.sh backup [/custom/backup/dir/custombackupname.zip]
|
||||
#
|
||||
backup() {
|
||||
APP_BASE_DIR=$(pwd)
|
||||
|
@ -199,7 +199,7 @@ backup() {
|
|||
#
|
||||
# Restore an AzuraCast backup into Docker.
|
||||
# Usage:
|
||||
# ./docker.sh restore [/custom/backup/dir/custombackupname.tar.gz]
|
||||
# ./docker.sh restore [/custom/backup/dir/custombackupname.zip]
|
||||
#
|
||||
restore() {
|
||||
APP_BASE_DIR=$(pwd)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
namespace App\Console\Command;
|
||||
|
||||
use App\Entity;
|
||||
use App\Utilities;
|
||||
use Azura\Console\Command\CommandAbstract;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Monolog\Logger;
|
||||
|
@ -44,7 +45,7 @@ class Backup extends CommandAbstract
|
|||
{
|
||||
$destination_path = $input->getArgument('path');
|
||||
if (empty($destination_path)) {
|
||||
$destination_path = 'manual_backup_'.gmdate('Ymd_Hi').'.tar.gz';
|
||||
$destination_path = 'manual_backup_'.gmdate('Ymd_Hi').'.zip';
|
||||
}
|
||||
if ('/' !== $destination_path[0]) {
|
||||
$destination_path = \App\Sync\Task\Backup::BASE_DIR.'/'.$destination_path;
|
||||
|
@ -161,17 +162,46 @@ class Backup extends CommandAbstract
|
|||
return $val;
|
||||
}, $files_to_backup);
|
||||
|
||||
$process = $this->passThruProcess($io, array_merge([
|
||||
'tar',
|
||||
'zcvf',
|
||||
$destination_path
|
||||
], $files_to_backup),'/');
|
||||
$file_ext = strtolower(pathinfo($destination_path, \PATHINFO_EXTENSION));
|
||||
|
||||
switch($file_ext) {
|
||||
case 'gz':
|
||||
case 'tgz':
|
||||
$process = $this->passThruProcess($io, array_merge([
|
||||
'tar',
|
||||
'zcvf',
|
||||
$destination_path
|
||||
], $files_to_backup),'/');
|
||||
break;
|
||||
|
||||
case 'zip':
|
||||
default:
|
||||
$dont_compress = ['.jpg', '.mp3', '.ogg', '.flac', '.aac', '.wav'];
|
||||
|
||||
$process = $this->passThruProcess($io, array_merge([
|
||||
'zip',
|
||||
'-r',
|
||||
'-n', implode(':', $dont_compress),
|
||||
$destination_path
|
||||
], $files_to_backup),'/');
|
||||
break;
|
||||
}
|
||||
|
||||
if (!$process->isSuccessful()) {
|
||||
$io->getErrorStyle()->error('An error occurred with the archive process.');
|
||||
return 1;
|
||||
}
|
||||
|
||||
$io->newLine();
|
||||
|
||||
// Cleanup
|
||||
$io->section('Cleaning up temporary files...');
|
||||
|
||||
Utilities::rmdirRecursive($tmp_dir_mariadb);
|
||||
Utilities::rmdirRecursive($tmp_dir_influxdb);
|
||||
|
||||
$io->newLine();
|
||||
|
||||
$io->success([
|
||||
'Backup complete!',
|
||||
]);
|
||||
|
|
|
@ -54,11 +54,26 @@ class Restore extends CommandAbstract
|
|||
// Extract tar.gz archive
|
||||
$io->section('Extracting backup file...');
|
||||
|
||||
$process = $this->passThruProcess($io, [
|
||||
'tar',
|
||||
'zxvf',
|
||||
$archive_path
|
||||
],'/');
|
||||
$file_ext = strtolower(pathinfo($archive_path, \PATHINFO_EXTENSION));
|
||||
|
||||
switch($file_ext) {
|
||||
case 'gz':
|
||||
case 'tgz':
|
||||
$process = $this->passThruProcess($io, [
|
||||
'tar',
|
||||
'zxvf',
|
||||
$archive_path
|
||||
],'/');
|
||||
break;
|
||||
|
||||
case 'zip':
|
||||
default:
|
||||
$process = $this->passThruProcess($io, [
|
||||
'unzip',
|
||||
$archive_path
|
||||
],'/');
|
||||
break;
|
||||
}
|
||||
|
||||
if (!$process->isSuccessful()) {
|
||||
$io->getErrorStyle()->error('An error occurred with the archive extraction.');
|
||||
|
|
|
@ -114,7 +114,7 @@ class Backup extends AbstractTask
|
|||
|
||||
// Trigger a new backup.
|
||||
$message = new Message\BackupMessage;
|
||||
$message->path = 'automatic_backup.tar.gz';
|
||||
$message->path = 'automatic_backup.zip';
|
||||
$message->exclude_media = (bool)$this->settings_repo->getSetting(Entity\Settings::BACKUP_EXCLUDE_MEDIA, 0);
|
||||
$this->message_queue->produce($message);
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ class RotateLogs extends AbstractTask
|
|||
$backups_to_keep = (int)$settings_repo->getSetting(Entity\Settings::BACKUP_KEEP_COPIES, 0);
|
||||
|
||||
if ($backups_to_keep > 0) {
|
||||
$rotate = new Rotate\Rotate(Backup::BASE_DIR . '/automatic_backup.tar.gz');
|
||||
$rotate = new Rotate\Rotate(Backup::BASE_DIR . '/automatic_backup.zip');
|
||||
$rotate->keep($backups_to_keep);
|
||||
$rotate->run();
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ $assets
|
|||
<?php if (APP_INSIDE_DOCKER): ?>
|
||||
<pre><code>./docker.sh restore path_to_backup.tar.gz</code></pre>
|
||||
<?php else: ?>
|
||||
<pre><code>/var/azuracast/www/bin/azuracast azuracast:restore path_to_backup.tar.gz</code></pre>
|
||||
<pre><code>/var/azuracast/www/bin/azuracast azuracast:restore path_to_backup.zip</code></pre>
|
||||
<?php endif; ?>
|
||||
|
||||
<p class="card-text text-warning"><?=__('Note that restoring a backup will clear your existing database. Never restore backup files from untrusted users.') ?></p>
|
||||
|
|
|
@ -45,6 +45,8 @@
|
|||
- pwgen
|
||||
- whois
|
||||
- python-pip
|
||||
- zip
|
||||
- unzip
|
||||
|
||||
- name: Install software-properties (18.04 only)
|
||||
apt:
|
||||
|
|
Loading…
Reference in New Issue