Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

small fixes #2

Merged
merged 2 commits into from
Jun 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ nix run .#run
- [x] WiFi:
- [x] Workspace aberto com capacidade para um máximo de 40 colaboradores
- [x] Duas salas de reuniões com rede dedicada, com capacidade para 10 colaboradores.
- [ ] Gestão de backups e logs:
- [ ] Os backups devem ser realizados todos os dias e armazenar sempre e apenas a última semana.
- [ ] Devem ser guardados apenas logs da última semana.
- [x] Gestão de backups e logs:
- [x] Os backups devem ser realizados todos os dias e armazenar sempre e apenas a última semana.
- [x] Devem ser guardados apenas logs da última semana.

## Entregas

Expand Down
18 changes: 18 additions & 0 deletions containers/backup.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,24 @@
enable = true;
};

environment.etc = {
"prune.sh" = {
enable = true;
text = ''
borg prune -v --list /var/bak/websites --keep-within=7d
borg prune -v --list /var/bak/log --keep-within=7d
'';
};
};

services.cron = {
enable = true;
# Run the prune script everyday at 2 AM
systemCronJobs = [
"0 2 * * * /etc/prune.sh"
];
};

services.borgbackup = {
repos."/var/bak/" = {
path = "/var/bak/";
Expand Down
1 change: 1 addition & 0 deletions containers/dhcp.nix
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
enable = true;

settings."/var/log/all.log" = {
compress = true;
postrotate = ''
find /var/log/*.log -mtime +7 -exec rm {} \;
'';
Expand Down
13 changes: 4 additions & 9 deletions containers/log.nix
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
mode = "none";
};
repo = "[email protected]:/var/bak/log";
startAt = "hourly";
startAt = "daily";
};
};

Expand All @@ -41,21 +41,16 @@
settings."multiple paths" = {
compress = true;
files = [
"/var/log/websites/nginx.log"
"/var/log/websites/mail"
"/var/log/websites/messages"

"/var/log/dhcp/kea.log"
"/var/log/dhcp/nginx.log"
"/var/log/dhcp/messages"
"/var/log/websites/*"
"/var/log/dhcp/*"
];

postrotate = ''
find /var/log/websites/*.log -mtime +7 -exec rm {} \;
find /var/log/dhcp/*.log -mtime +7 -exec rm {} \;
'';
frequency = "hourly";
rotate = 1;
rotate = 4;
};
};

Expand Down
2 changes: 1 addition & 1 deletion containers/websites.nix
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ in
mode = "none";
};
repo = "[email protected]:/var/bak/websites";
startAt = "hourly";
startAt = "daily";
};
};

Expand Down