Home : Add bin dir.
This commit is contained in:
parent
7911bc4548
commit
a3cb469cc2
|
@ -4,7 +4,7 @@
|
||||||
description = "Home system backup.";
|
description = "Home system backup.";
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "oneshot";
|
Type = "oneshot";
|
||||||
ExecStart = "/root/app/bin/home/Backup";
|
ExecStart = "/etc/bin/Backup";
|
||||||
};
|
};
|
||||||
path = with pkgs; [
|
path = with pkgs; [
|
||||||
bashInteractive
|
bashInteractive
|
||||||
|
|
|
@ -18,6 +18,9 @@
|
||||||
10.1.0.2 pass.voronind.com
|
10.1.0.2 pass.voronind.com
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
# Extra binaries.
|
||||||
|
environment.etc.bin.source = ./bin;
|
||||||
|
|
||||||
# Filesystems.
|
# Filesystems.
|
||||||
fileSystems."/storage/cold_1" = {
|
fileSystems."/storage/cold_1" = {
|
||||||
device = "/dev/storage/cold_1";
|
device = "/dev/storage/cold_1";
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
description = "Nextcloud worker.";
|
description = "Nextcloud worker.";
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "oneshot";
|
Type = "oneshot";
|
||||||
ExecStart = "/root/app/bin/home/Nextcloud";
|
ExecStart = "/etc/bin/Nextcloud";
|
||||||
};
|
};
|
||||||
path = with pkgs; [
|
path = with pkgs; [
|
||||||
bashInteractive
|
bashInteractive
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
description = "Process uploaded photos.";
|
description = "Process uploaded photos.";
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "oneshot";
|
Type = "oneshot";
|
||||||
ExecStart = "/root/app/bin/home/PhotosProcess";
|
ExecStart = "/etc/bin/PhotosProcess";
|
||||||
};
|
};
|
||||||
path = with pkgs; [
|
path = with pkgs; [
|
||||||
bashInteractive
|
bashInteractive
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
description = "Sync music from Yandex.Music.";
|
description = "Sync music from Yandex.Music.";
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "oneshot";
|
Type = "oneshot";
|
||||||
ExecStart = "/root/app/bin/home/YandexMusic";
|
ExecStart = "/etc/bin/YandexMusic";
|
||||||
};
|
};
|
||||||
path = with pkgs; [
|
path = with pkgs; [
|
||||||
bashInteractive
|
bashInteractive
|
||||||
|
|
76
host/home/bin/Backup
Executable file
76
host/home/bin/Backup
Executable file
|
@ -0,0 +1,76 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Source modules.
|
||||||
|
for file in /etc/bash/module/*.sh; do
|
||||||
|
source "${file}"
|
||||||
|
done
|
||||||
|
|
||||||
|
function report() {
|
||||||
|
echo "${*}"
|
||||||
|
notify "${*}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Define constants.
|
||||||
|
path_src="/storage/hot"
|
||||||
|
path_mount="/storage/cold_1"
|
||||||
|
path_backup="${path_mount}/backup"
|
||||||
|
path_docker="${path_backup}/home"
|
||||||
|
path_media="/storage/cold_1/media /storage/cold_2/media"
|
||||||
|
|
||||||
|
# Check if backup drive is mounted.
|
||||||
|
if [ ! -f "${path_mount}"/.mount ]; then
|
||||||
|
report "Backup : ${path_mount} not mounted!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if hot storage is mounted.
|
||||||
|
if [ ! -f "${path_src}"/.mount ]; then
|
||||||
|
report "Backup : ${path_src} not mounted!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Cd to src storage.
|
||||||
|
cd "${path_src}"
|
||||||
|
|
||||||
|
# Save media list.
|
||||||
|
find ${path_media} -type d > ${path_backup}/cold/ColdMedia.txt || report "Backup : Failed to save media list!"
|
||||||
|
cd ${path_backup}/cold/
|
||||||
|
archive_fast ColdMedia.txt && rm ColdMedia.txt || report "Backup : Failed to archive media list!"
|
||||||
|
cd -
|
||||||
|
|
||||||
|
# Backup docker.
|
||||||
|
docker=$(archive_fast docker/)
|
||||||
|
bupsize=$(tdu ${docker} | awk '{print $1}')
|
||||||
|
mv ${docker} ${path_docker}/ || report "Backup : Failed to save docker!"
|
||||||
|
|
||||||
|
# Backup some media.
|
||||||
|
cd ${path_src}/media/
|
||||||
|
paper=$(archive_fast paper/)
|
||||||
|
mv ${paper} ${path_backup}/paper/ || report "Backup : Failed to save paper!"
|
||||||
|
cd -
|
||||||
|
|
||||||
|
# Prune media copies.
|
||||||
|
cd ${path_backup}/paper/
|
||||||
|
archive_prune
|
||||||
|
cd -
|
||||||
|
|
||||||
|
cd ${path_backup}/cold/
|
||||||
|
archive_prune
|
||||||
|
cd -
|
||||||
|
|
||||||
|
# Prune old Docker copies.
|
||||||
|
cd ${path_docker}
|
||||||
|
archive_prune Docker 7
|
||||||
|
cd -
|
||||||
|
|
||||||
|
# Prune game saves.
|
||||||
|
cd "${path_backup}/save/"
|
||||||
|
archive_prune
|
||||||
|
cd -
|
||||||
|
|
||||||
|
# Sync writes.
|
||||||
|
sync
|
||||||
|
|
||||||
|
# Notify completion & size.
|
||||||
|
notify_silent "Backup : Complete ${bupsize}."
|
||||||
|
echo "Backup : Complete ${bupsize}."
|
8
host/home/bin/Nextcloud
Executable file
8
host/home/bin/Nextcloud
Executable file
|
@ -0,0 +1,8 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Source modules.
|
||||||
|
for file in /etc/bash/module/*.sh; do
|
||||||
|
source "${file}"
|
||||||
|
done
|
||||||
|
|
||||||
|
docker exec -u 33 cloud php -f /var/www/html/cron.php || notify 'Nextcloud : Failed to run cron.'
|
6
host/home/bin/PhotosProcess
Executable file
6
host/home/bin/PhotosProcess
Executable file
|
@ -0,0 +1,6 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
in="/storage/hot/docker/cloud/data/data/cakee/files/media/photo/"
|
||||||
|
out="/storage/cold_1/backup/tmp/photo/"
|
||||||
|
|
||||||
|
docker run --rm -v "${in}":/in -v "${out}":/out voronind.com/photoprocess:latest
|
5
host/home/bin/YandexMusic
Executable file
5
host/home/bin/YandexMusic
Executable file
|
@ -0,0 +1,5 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
music="/storage/hot/media/music/"
|
||||||
|
|
||||||
|
docker run --rm -v "${music}":/music voronind.com/yamusic:latest
|
Loading…
Reference in a new issue