Files
crm.clientright.ru/README_GIT.md
Fedor ac7467f0b4 Major CRM updates: AI Assistant, Court Status API, S3 integration improvements, and extensive file storage system
- Added comprehensive AI Assistant system (aiassist/ directory):
  * Vector search and embedding capabilities
  * Typebot proxy integration
  * Elastic search functionality
  * Message classification and chat history
  * MCP proxy for external integrations

- Implemented Court Status API (GetCourtStatus.php):
  * Real-time court document status checking
  * Integration with external court systems
  * Comprehensive error handling and logging

- Enhanced S3 integration:
  * Improved file backup system with metadata
  * Batch processing capabilities
  * Enhanced error logging and recovery
  * Copy operations with URL fixing

- Added Telegram contact creation API
- Improved error logging across all modules
- Enhanced callback system for AI responses
- Extensive backup file storage with timestamps
- Updated documentation and README files

- File storage improvements:
  * Thousands of backup files with proper metadata
  * Fix operations for broken file references
  * Project-specific backup and recovery systems
  * Comprehensive file integrity checking

Total: 26,461+ files added/modified including AWS SDK, vendor dependencies, and extensive backup system.
2025-10-16 11:17:21 +03:00

167 lines
4.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Git Backup System для CRM
## Обзор
Система автоматического бэкапа Git репозитория CRM проекта с возможностью загрузки на S3.
## Файлы
- `backup_to_s3.sh` - Основной скрипт бэкапа с загрузкой на S3
- `daily_backup.sh` - Простой ежедневный бэкап
- `.gitignore` - Исключения для Git
- `backups/` - Папка для локальных бэкапов
## Использование
### Ручной бэкап
```bash
# Создать бэкап с описанием
./backup_to_s3.sh "Описание изменений"
# Создать бэкап с автоматическим описанием
./backup_to_s3.sh
```
### Автоматический ежедневный бэкап
```bash
# Добавить в crontab для ежедневного бэкапа в 2:00
crontab -e
# Добавить строку:
0 2 * * * /var/www/fastuser/data/www/crm.clientright.ru/daily_backup.sh
```
## Настройка S3
### 1. Установка AWS CLI
```bash
# Ubuntu/Debian
sudo apt install awscli
# Или через pip
pip install awscli
```
### 2. Настройка credentials
```bash
aws configure
# Ввести:
# AWS Access Key ID: [ваш ключ]
# AWS Secret Access Key: [ваш секрет]
# Default region name: ru-central1
# Default output format: json
```
### 3. Создание S3 bucket
```bash
aws s3 mb s3://crm-backups --region ru-central1
```
## Структура бэкапов
### Git коммиты
- Каждый бэкап создает коммит с временной меткой
- История изменений сохраняется в Git
### Архивы
- Формат: `crm_backup_YYYYMMDD_HHMMSS.tar.gz`
- Исключения: `.git`, `cache`, `logs`, `test`
- Размер: обычно 50-100MB
### S3 структура
```
s3://crm-backups/
├── crm-git-backup/
│ ├── crm_backup_20240926_104500.tar.gz
│ ├── crm_backup_20240926_120000.tar.gz
│ └── ...
```
## Восстановление
### Из Git
```bash
# Посмотреть историю
git log --oneline
# Откатиться к предыдущей версии
git reset --hard HEAD~1
# Откатиться к конкретному коммиту
git reset --hard <commit-hash>
```
### Из архива
```bash
# Скачать с S3
aws s3 cp s3://crm-backups/crm-git-backup/crm_backup_20240926_104500.tar.gz .
# Распаковать
tar -xzf crm_backup_20240926_104500.tar.gz
```
## Мониторинг
### Проверка статуса
```bash
# Статус Git
git status
# Последние коммиты
git log --oneline -10
# Размер репозитория
du -sh .git
```
### Логи
```bash
# Логи ежедневного бэкапа
tail -f /var/log/cron
# Или добавить логирование в скрипт
./daily_backup.sh >> /var/log/crm_backup.log 2>&1
```
## Безопасность
### Исключенные файлы
- `config.inc.php` - конфигурация БД
- `.env` - переменные окружения
- `cache/` - кеш файлы
- `logs/` - логи
- `*.log` - все лог файлы
### Рекомендации
1. Регулярно проверяйте размер бэкапов
2. Настройте lifecycle policy для S3
3. Используйте разные bucket для разных окружений
4. Шифруйте sensitive данные
## Troubleshooting
### Проблема: "Permission denied"
```bash
sudo chown -R www-data:www-data .
sudo chmod -R 755 .
```
### Проблема: "AWS CLI not found"
```bash
# Установить AWS CLI
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
```
### Проблема: "Bucket does not exist"
```bash
# Создать bucket
aws s3 mb s3://crm-backups --region ru-central1
```
## Контакты
При проблемах обращайтесь к Фёдору.