mirror of
https://github.com/Nickiel12/nicks-nix-config.git
synced 2024-11-22 20:59:32 -08:00
added forgejo and gitea backups to script
This commit is contained in:
parent
1026fe3821
commit
3584c3c6fb
2 changed files with 17 additions and 15 deletions
|
@ -25,7 +25,7 @@
|
||||||
backup1_drive_label = "AlaskaBackup";
|
backup1_drive_label = "AlaskaBackup";
|
||||||
|
|
||||||
vaultwarden = {
|
vaultwarden = {
|
||||||
enable = false;
|
enable = true;
|
||||||
backup_dir = "/Aurora/Backups/Vaultwarden";
|
backup_dir = "/Aurora/Backups/Vaultwarden";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
nextcloud = {
|
nextcloud = {
|
||||||
enable = false;
|
enable = true;
|
||||||
root_dir = /Aurora/nextcloud;
|
root_dir = /Aurora/nextcloud;
|
||||||
db_server = "127.0.0.1";
|
db_server = "127.0.0.1";
|
||||||
db_name = "nextcloud";
|
db_name = "nextcloud";
|
||||||
|
|
|
@ -122,6 +122,7 @@ in
|
||||||
description = "Alaska Nightly Backup Service";
|
description = "Alaska Nightly Backup Service";
|
||||||
onFailure = [ "alaska_backup_script_onfail.service" ];
|
onFailure = [ "alaska_backup_script_onfail.service" ];
|
||||||
path = with pkgs; [
|
path = with pkgs; [
|
||||||
|
gawk
|
||||||
config.services.nextcloud.occ
|
config.services.nextcloud.occ
|
||||||
config.services.postgresql.package
|
config.services.postgresql.package
|
||||||
config.services.gitea.package
|
config.services.gitea.package
|
||||||
|
@ -139,7 +140,7 @@ in
|
||||||
mount /dev/disk/by-label/${cfg.backup1_drive_label} ${builtins.toString cfg.tmp_mount_point} -t ntfs3
|
mount /dev/disk/by-label/${cfg.backup1_drive_label} ${builtins.toString cfg.tmp_mount_point} -t ntfs3
|
||||||
|
|
||||||
#------ BEGIN NEXTCLOUD
|
#------ BEGIN NEXTCLOUD
|
||||||
if [ "${builtins.toString cfg.nextcloud.enable}" = true ]; then
|
if [ "${builtins.toString cfg.nextcloud.enable}" = "1" ]; then
|
||||||
echo "Putting nextcloud into maintenance mode so that changes cannot happen during the backup"
|
echo "Putting nextcloud into maintenance mode so that changes cannot happen during the backup"
|
||||||
nextcloud-occ maintenance:mode --on
|
nextcloud-occ maintenance:mode --on
|
||||||
|
|
||||||
|
@ -163,29 +164,30 @@ in
|
||||||
#---- END NEXTCLOUD
|
#---- END NEXTCLOUD
|
||||||
|
|
||||||
#---- BEGIN FORGEJO
|
#---- BEGIN FORGEJO
|
||||||
if [ "${builtins.toString cfg.forgejo.enable}" = true ]; then
|
if [ "${builtins.toString cfg.forgejo.enable}" = "1" ]; then
|
||||||
echo "deleting old Forgejo backups"
|
echo "deleting old Forgejo backups"
|
||||||
find ${builtins.toString cfg.tmp_mount_point}/Forgejo -type f -printf '%T+ %p\n'\
|
find ${builtins.toString cfg.tmp_mount_point}/Forgejo -type f -printf '%T+ %p\n' \
|
||||||
| sort | head -n -${builtins.toString cfg.forgejo.save_old_count}\
|
| sort | head -n -${builtins.toString cfg.forgejo.save_old_count} \
|
||||||
| awk '{print $2}'\
|
| gawk '{print $2}' \
|
||||||
| xargs rm
|
| xargs rm || true
|
||||||
|
|
||||||
echo "Copying Forgejo backup"
|
echo "Copying Forgejo backup"
|
||||||
cp `find ${builtins.toString cfg.forgejo.backups_dir} -type f -printf '%T+ %p\n'\
|
latest_backup=$(find ${builtins.toString cfg.forgejo.backups_dir} -type f -printf '%T+ %p\n' \
|
||||||
| grep *.${builtins.toString config.services.gitea.dump.type}
|
| grep .${builtins.toString config.services.gitea.dump.type} \
|
||||||
| sort | head -n 1 | awk '{print $2}'` ${builtins.toString cfg.tmp_mount_point}/Forgejo
|
| sort | head -n 1 | gawk '{print $2}')
|
||||||
|
cp "$latest_backup" ${builtins.toString cfg.tmp_mount_point}/Forgejo
|
||||||
|
|
||||||
echo "Clearing old Forgejo backups"
|
echo "Clearing old Forgejo backups"
|
||||||
find ${builtins.toString cfg.forgejo.backups_dir} -type f -printf '%T+ %p\n'\
|
find ${builtins.toString cfg.forgejo.backups_dir} -type f -printf '%T+ %p\n'\
|
||||||
| sort | head -n -${builtins.toString cfg.forgejo.save_old_count}\
|
| sort | head -n -${builtins.toString cfg.forgejo.save_old_count}\
|
||||||
| awk '{print $2}'\
|
| gawk '{print $2}'\
|
||||||
| xargs rm
|
| xargs rm || true
|
||||||
fi
|
fi
|
||||||
#----- END FORGEJO
|
#----- END FORGEJO
|
||||||
|
|
||||||
#----- BEGIN VAULTWARDEN
|
#----- BEGIN VAULTWARDEN
|
||||||
if [ "${builtins.toString cfg.vaultwarden.enable}" = true]; then
|
if [ "${builtins.toString cfg.vaultwarden.enable}" = "1" ]; then
|
||||||
rsync -av ${cfg.vaultwarden.backup_dir} ${builtins.toString cfg.tmp_mount_point}/Vaultwarden
|
rsync -av ${cfg.vaultwarden.backup_dir} ${builtins.toString cfg.tmp_mount_point}
|
||||||
|
|
||||||
fi
|
fi
|
||||||
#----- END VAULTWARDEN
|
#----- END VAULTWARDEN
|
||||||
|
|
Loading…
Reference in a new issue