File size: 1,090 Bytes
5b7b3d4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash

# سكريبت النسخ الاحتياطي لقاعدة البيانات

BACKUP_DIR="backups"
TIMESTAMP=$(date +"%Y%m%d_%H%M%S")
BACKUP_NAME="aefrs_backup_${TIMESTAMP}"

echo "🔄 Starting AEFRS backup..."

# إنشاء مجلد النسخ الاحتياطي
mkdir -p $BACKUP_DIR

# نسخ قاعدة البيانات
if [ -f "database/identities.db" ]; then
    cp database/identities.db "${BACKUP_DIR}/${BACKUP_NAME}.db"
    echo "✅ Database backed up"
fi

# نسخ المتجهات
if [ -d "database/vector_index" ]; then
    cp -r database/vector_index "${BACKUP_DIR}/${BACKUP_NAME}_vectors"
    echo "✅ Vector index backed up"
fi

# إنشاء ملف مضغوط
tar -czf "${BACKUP_DIR}/${BACKUP_NAME}.tar.gz" -C $BACKUP_DIR "${BACKUP_NAME}.db" "${BACKUP_NAME}_vectors" 2>/dev/null

# تنظيف الملفات المؤقتة
rm -rf "${BACKUP_DIR}/${BACKUP_NAME}.db" "${BACKUP_DIR}/${BACKUP_NAME}_vectors"

# الاحتفاظ بآخر 7 نسخ فقط
cd $BACKUP_DIR
ls -t *.tar.gz | tail -n +8 | xargs -r rm
cd ..

echo "✅ Backup completed: ${BACKUP_NAME}.tar.gz"