Skip to content

Commit fad8ce1

Browse files
add backup files
1 parent 5c21286 commit fad8ce1

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

README.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,30 @@ https://habr.com/ru/companies/softpoint/articles/795305/ - Бэкап, бэка
1717

1818
```
1919
git add .
20-
git commit -m "add utils.md"
20+
git commit -m "add backup files"
2121
git push -u origin main
2222
```
2323

2424

2525

2626
# Плейбук Ansible для резервного копирования MongoDB и PostgreSQL
27-
/Users/andreyshabunov/PhpstormProjects/db-backups/backup_databases.yml
27+
/Users/andreyshabunov/PhpstormProjects/db-backups/backup_postgre.yml
28+
/Users/andreyshabunov/PhpstormProjects/db-backups/backup_mongo.yml
29+
30+
Команды:
31+
```
32+
# Создание резервной копии всех баз данных PostgreSQL
33+
pg_dumpall --file=/backups/postgresql_backup_$(date +%F_%H%M%S)
34+
35+
# Выполнение резервного копирования MongoDB
36+
mongodump --out /backups/mongodb_backup_$(date +%F_%H%M%S)
37+
```
38+
Результат:
39+
```
40+
postgres@juice-shop-server:~$ ls -l /backups/
41+
total 24
42+
drwxr-xr-x 3 root root 4096 Mar 14 14:14 mongodb_backup_2025-03-14_141436
43+
drwxr-xr-x 3 root root 4096 Mar 14 14:18 mongodb_backup_2025-03-14_141806
44+
-rw-rw-r-- 1 postgres postgres 4591 Mar 14 14:33 postgresql_backup_2025-03-14_143307
45+
-rw-rw-r-- 1 postgres postgres 4591 Mar 14 14:35 postgresql_backup_2025-03-14_143537
46+
```

backup_mongo.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
file:
88
path: /backups
99
state: directory
10-
mode: '0755'
10+
mode: '0777'
1111

1212
# Backup MongoDB
1313
- name: Backup MongoDB

backup_postgre.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
---
22
- name: Backup PostgreSQL Database
33
hosts: serverspace_host_postgres
4-
become: yes # Запуск от имени суперпользователя
4+
become: no # Запуск от имени суперпользователя
55
tasks:
66
- name: Create backup directory
77
file:
88
path: /backups
99
state: directory
10-
mode: '0755'
10+
mode: '0777'
1111

1212
# Backup PostgreSQL
1313
- name: Backup PostgreSQL

0 commit comments

Comments
 (0)