forked from AFPy/infra
Backuping gitea.
This commit is contained in:
parent
daed7462ad
commit
a48fb10a30
|
@ -38,3 +38,6 @@
|
||||||
path: deb.afpy.org/
|
path: deb.afpy.org/
|
||||||
- remote: deb2.afpy.org:/var/www/
|
- remote: deb2.afpy.org:/var/www/
|
||||||
path: deb.afpy.org/
|
path: deb.afpy.org/
|
||||||
|
|
||||||
|
- remote: gitea1.afpy.org:/var/backups/
|
||||||
|
path: git.afpy.org/
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
# It's possible to see some info about the timer using:
|
||||||
|
#
|
||||||
|
# systemctl list-timers gitea-backup
|
||||||
|
# systemctl status gitea-backup.service
|
||||||
|
|
||||||
|
|
||||||
|
- name: Create backup script
|
||||||
|
copy:
|
||||||
|
dest: /usr/local/bin/gitea-backup.sh
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0750
|
||||||
|
content: |
|
||||||
|
#!/bin/sh
|
||||||
|
rm -fr /var/backups/gitea
|
||||||
|
mkdir /var/backups/gitea
|
||||||
|
systemctl stop gitea
|
||||||
|
chown git:git /var/backups/gitea/
|
||||||
|
GITEA_WORK_DIR=/var/lib/gitea sudo -u git --preserve-env=GITEA_WORK_DIR gitea dump -c /etc/gitea/app.ini --file /var/backups/gitea/gitea.zip
|
||||||
|
sudo -u git pg_dump gitea > /var/backups/gitea/gitea.sql
|
||||||
|
chown root:root /var/backups/gitea
|
||||||
|
chmod 700 /var/backups/gitea/
|
||||||
|
systemctl start gitea
|
||||||
|
|
||||||
|
- name: Create backup service
|
||||||
|
copy:
|
||||||
|
dest: /etc/systemd/system/gitea-backup.service
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0644
|
||||||
|
content: |
|
||||||
|
[Unit]
|
||||||
|
Description=Backup gitea
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStart=/usr/local/bin/gitea-backup.sh
|
||||||
|
|
||||||
|
- name: Create backup timer
|
||||||
|
copy:
|
||||||
|
dest: /etc/systemd/system/gitea-backup.timer
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0644
|
||||||
|
content: |
|
||||||
|
[Unit]
|
||||||
|
Description=Daily gitea backup
|
||||||
|
|
||||||
|
[Timer]
|
||||||
|
OnCalendar=*-*-* 03:00:00
|
||||||
|
|
||||||
|
- name: Start backup timer
|
||||||
|
service: name=gitea-backup.timer state=started daemon_reload=yes
|
|
@ -1,13 +1,13 @@
|
||||||
---
|
---
|
||||||
|
|
||||||
- name: Setup app.ini
|
- name: Setup app.ini
|
||||||
notify: restart gitea
|
|
||||||
template:
|
template:
|
||||||
src: app.ini.j2
|
src: app.ini.j2
|
||||||
dest: /etc/gitea/app.ini
|
dest: /etc/gitea/app.ini
|
||||||
mode: 0640
|
mode: 0640
|
||||||
owner: root
|
owner: root
|
||||||
group: git
|
group: git
|
||||||
|
notify: restart gitea
|
||||||
|
|
||||||
- name: Setup gitea systemd service
|
- name: Setup gitea systemd service
|
||||||
template:
|
template:
|
||||||
|
@ -16,6 +16,7 @@
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: 0644
|
mode: 0644
|
||||||
|
notify: restart gitea
|
||||||
|
|
||||||
- name: extra links footer
|
- name: extra links footer
|
||||||
copy:
|
copy:
|
||||||
|
|
|
@ -6,5 +6,8 @@
|
||||||
- include: config.yml
|
- include: config.yml
|
||||||
tags: config
|
tags: config
|
||||||
|
|
||||||
|
- include: backup.yml
|
||||||
|
tags: backup
|
||||||
|
|
||||||
- name: Start gitea
|
- name: Start gitea
|
||||||
service: name=gitea enabled=yes state=started daemon_reload=yes
|
service: name=gitea enabled=yes state=started daemon_reload=yes
|
||||||
|
|
|
@ -4,6 +4,7 @@ After=syslog.target
|
||||||
After=network.target
|
After=network.target
|
||||||
Wants=postgresql.service
|
Wants=postgresql.service
|
||||||
After=postgresql.service
|
After=postgresql.service
|
||||||
|
Requires=gitea-backup.timer
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
RestartSec=2s
|
RestartSec=2s
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
30 3 * * * root /usr/bin/rsnapshot -c /etc/rsnapshot_{{ rsnapshot_name }}.conf daily
|
0 5 * * * root /usr/bin/rsnapshot -c /etc/rsnapshot_{{ rsnapshot_name }}.conf daily
|
||||||
0 3 * * 1 root /usr/bin/rsnapshot -c /etc/rsnapshot_{{ rsnapshot_name }}.conf weekly
|
30 4 * * 1 root /usr/bin/rsnapshot -c /etc/rsnapshot_{{ rsnapshot_name }}.conf weekly
|
||||||
30 2 1 * * root /usr/bin/rsnapshot -c /etc/rsnapshot_{{ rsnapshot_name }}.conf monthly
|
0 4 1 * * root /usr/bin/rsnapshot -c /etc/rsnapshot_{{ rsnapshot_name }}.conf monthly
|
||||||
0 1 1 1 * root /usr/bin/rsnapshot -c /etc/rsnapshot_{{ rsnapshot_name }}.conf yearly
|
30 3 1 1 * root /usr/bin/rsnapshot -c /etc/rsnapshot_{{ rsnapshot_name }}.conf yearly
|
||||||
|
|
Loading…
Reference in New Issue