Cesivi Server - Export/Import Guide¶
Home → Documentation → Usage → Export/Import
Complete guide for backing up, migrating, and restoring Cesivi Server data.
Table of Contents¶
- Overview
- Quick Start
- Exporting Storage
- Importing Storage
- Backup Strategies
- Environment Migration
- Docker Integration
- Troubleshooting
Overview¶
What is Export/Import?¶
The Export/Import feature allows you to package the entire Mock Server storage (@MockData folder) as a single ZIP file for backup, migration, or sharing.
Use Cases¶
- Backup - Save state before making changes
- Migration - Move data between environments (dev/staging/prod)
- Sharing - Share test datasets with team members
- Versioning - Maintain multiple data snapshots
- Disaster Recovery - Restore from backup after failures
What Gets Exported¶
- Site collections and webs
- Lists and libraries (metadata)
- List items and documents
- File content
- Users and groups
- Permissions
- Content types
- Site columns
Quick Start¶
Export Current State¶
REST API:
curl -X POST http://localhost:5000/_api/admin/storage/export \
-H "Content-Type: application/json" \
-d '{}'
Response:
{
"success": true,
"filePath": "@MockData/.exports/mockdata-export-20251115-102030.zip",
"fileSize": 15728640,
"siteCollectionCount": 3,
"listCount": 25,
"fileCount": 1234,
"timestamp": "2025-11-15T10:20:30Z"
}
Import from Backup¶
REST API:
curl -X POST http://localhost:5000/_api/admin/storage/import-from-file \
-H "Content-Type: application/json" \
-d '{
"fileName": "mockdata-export-20251115-102030.zip",
"options": {
"mode": "Replace",
"createBackup": true
}
}'
Exporting Storage¶
Export Options¶
Full Export (default):
curl -X POST http://localhost:5000/_api/admin/storage/export \
-H "Content-Type: application/json" \
-d '{
"includeSiteCollections": true,
"includeLists": true,
"includeFiles": true,
"includeUsers": true,
"includePermissions": true,
"includeContentTypes": true,
"includeSiteColumns": true,
"compressionLevel": 6
}'
Metadata-Only Export (no files):
curl -X POST http://localhost:5000/_api/admin/storage/export \
-H "Content-Type: application/json" \
-d '{
"includeSiteCollections": true,
"includeLists": true,
"includeFiles": false,
"compressionLevel": 9
}'
Export Configuration¶
| Property | Type | Default | Description |
|---|---|---|---|
includeSiteCollections |
bool | true |
Include all site collections |
includeLists |
bool | true |
Include all lists/libraries |
includeFiles |
bool | true |
Include file content |
includeUsers |
bool | true |
Include users and groups |
includePermissions |
bool | true |
Include permissions |
includeContentTypes |
bool | true |
Include content types |
includeSiteColumns |
bool | true |
Include site columns |
compressionLevel |
int | 6 |
Compression (0-9) |
Compression Levels¶
- 0 - No compression (fastest, largest file)
- 1-5 - Fast compression
- 6 - Optimal compression (default)
- 7-9 - Maximum compression (slowest, smallest file)
Export File Location¶
Exports are saved to @MockData/.exports/:
@MockData/
├── .exports/
│ ├── mockdata-export-20251115-102030.zip
│ ├── mockdata-export-20251115-143000.zip
│ └── mockdata-export-20251115-160000.zip
└── sites/
└── ...
The .exports folder is not deleted during Replace imports.
List Available Exports¶
REST API:
curl http://localhost:5000/_api/admin/storage/exports
Response:
[
{
"fileName": "mockdata-export-20251115-102030.zip",
"filePath": "C:\\Projects\\@MockData\\.exports\\mockdata-export-20251115-102030.zip",
"fileSize": 15728640,
"created": "2025-11-15T10:20:30Z"
},
{
"fileName": "mockdata-export-20251115-143000.zip",
"filePath": "C:\\Projects\\@MockData\\.exports\\mockdata-export-20251115-143000.zip",
"fileSize": 8388608,
"created": "2025-11-15T14:30:00Z"
}
]
Download Export File¶
REST API:
curl http://localhost:5000/_api/admin/storage/exports/mockdata-export-20251115-102030.zip \
-o backup.zip
Importing Storage¶
Import Modes¶
Replace Mode¶
Deletes ALL existing data and extracts ZIP contents.
curl -X POST http://localhost:5000/_api/admin/storage/import-from-file \
-H "Content-Type: application/json" \
-d '{
"fileName": "mockdata-export-20251115-102030.zip",
"options": {
"mode": "Replace",
"createBackup": true
}
}'
Use When: - Complete environment refresh - Restoring from backup - Starting fresh with new dataset
Important: Creates automatic backup before deletion.
Merge Mode¶
Keeps existing data and adds/updates from ZIP.
curl -X POST http://localhost:5000/_api/admin/storage/import-from-file \
-H "Content-Type: application/json" \
-d '{
"fileName": "mockdata-export-20251115-102030.zip",
"options": {
"mode": "Merge",
"createBackup": true,
"overwriteExisting": false
}
}'
Use When: - Adding new data to existing storage - Updating specific items - Incremental updates
Import Options¶
| Property | Type | Default | Description |
|---|---|---|---|
mode |
string | Merge |
"Replace" or "Merge" |
createBackup |
bool | true |
Backup before import |
overwriteExisting |
bool | false |
Overwrite files in Merge |
validateBeforeImport |
bool | true |
Validate ZIP structure |
Upload External ZIP¶
REST API (multipart/form-data):
curl -X POST http://localhost:5000/_api/admin/storage/import \
-F "file=@backup.zip" \
-F "mode=replace" \
-F "createBackup=true"
Upload Limit: 500 MB (configurable in code)
Import Response¶
{
"success": true,
"backupFilePath": "@MockData/.exports/mockdata-export-20251115-102035.zip",
"siteCollectionCount": 3,
"listCount": 25,
"fileCount": 1234,
"validationErrors": [],
"warnings": ["Skipped existing file: sites/site1/web.json"],
"timestamp": "2025-11-15T10:20:45Z"
}
Backup Strategies¶
Strategy 1: Before Major Changes¶
# Create backup
BACKUP=$(curl -s -X POST http://localhost:5000/_api/admin/storage/export \
-H "Content-Type: application/json" -d '{}' | jq -r '.filePath')
echo "Backup created: $BACKUP"
# Make your changes...
# If needed, restore
curl -X POST http://localhost:5000/_api/admin/storage/import-from-file \
-H "Content-Type: application/json" \
-d "{\"fileName\": \"$(basename $BACKUP)\", \"options\": {\"mode\": \"Replace\"}}"
Strategy 2: Scheduled Backups¶
PowerShell Script:
# backup-schedule.ps1
$serverUrl = "http://localhost:5000"
$backupPath = "C:\Backups\Cesivi"
# Create daily backup
$date = Get-Date -Format "yyyy-MM-dd"
$exportResult = Invoke-RestMethod -Uri "$serverUrl/_api/admin/storage/export" `
-Method Post `
-Body '{}' `
-ContentType "application/json"
# Download export
$exportFile = $exportResult.filePath.Split('\')[-1]
$downloadUrl = "$serverUrl/_api/admin/storage/exports/$exportFile"
Invoke-WebRequest -Uri $downloadUrl -OutFile "$backupPath\backup-$date.zip"
Write-Host "Backup saved: $backupPath\backup-$date.zip"
# Cleanup old backups (keep last 7 days)
Get-ChildItem $backupPath -Filter "backup-*.zip" |
Where-Object { $_.CreationTime -lt (Get-Date).AddDays(-7) } |
Remove-Item
Windows Task Scheduler:
# Run daily at 2 AM
$action = New-ScheduledTaskAction -Execute "PowerShell.exe" -Argument "-File C:\Scripts\backup-schedule.ps1"
$trigger = New-ScheduledTaskTrigger -Daily -At 2am
Register-ScheduledTask -TaskName "CesiviBackup" -Action $action -Trigger $trigger
Strategy 3: Version Control Integration¶
# Git workflow
cd @MockData
# Export current state
curl -s -X POST http://localhost:5000/_api/admin/storage/export \
-H "Content-Type: application/json" -d '{}'
# Commit to Git
git add .exports/mockdata-export-*.zip
git commit -m "Backup: $(date +%Y-%m-%d)"
git tag "backup-$(date +%Y%m%d)"
git push --tags
Environment Migration¶
Development → Staging¶
Step 1: Export from Development
curl -X POST http://dev.mocksharepoint.local/_api/admin/storage/export \
-H "Content-Type: application/json" -d '{}' > dev-export.json
EXPORT_FILE=$(jq -r '.filePath' dev-export.json | xargs basename)
curl http://dev.mocksharepoint.local/_api/admin/storage/exports/$EXPORT_FILE \
-o dev-data.zip
Step 2: Import to Staging
curl -X POST http://staging.mocksharepoint.local/_api/admin/storage/import \
-F "file=@dev-data.zip" \
-F "mode=replace" \
-F "createBackup=true"
Staging → Production¶
With Approval Process:
# 1. Export from staging
$exportResult = Invoke-RestMethod -Uri "http://staging/_api/admin/storage/export" `
-Method Post -Body '{}' -ContentType "application/json"
# 2. Download and verify
$exportFile = $exportResult.filePath.Split('\')[-1]
Invoke-WebRequest -Uri "http://staging/_api/admin/storage/exports/$exportFile" `
-OutFile "staging-export.zip"
# 3. Manual verification/approval
# 4. Import to production
Invoke-RestMethod -Uri "http://prod/_api/admin/storage/import" `
-Method Post `
-Form @{
file = Get-Item "staging-export.zip"
mode = "replace"
createBackup = "true"
}
Docker Integration¶
Export from Container¶
# Export inside container
docker exec cesivi curl -X POST http://localhost/_api/admin/storage/export \
-H "Content-Type: application/json" -d '{}'
# Copy to host
docker cp cesivi:/app/@MockData/.exports/mockdata-export-20251115-102030.zip ./
Import to Container¶
# Copy ZIP to container
docker cp ./backup.zip cesivi:/tmp/
# Import from inside container
docker exec cesivi curl -X POST http://localhost/_api/admin/storage/import \
-F "file=@/tmp/backup.zip" \
-F "mode=replace"
Docker Volume Persistence¶
docker-compose.yml:
services:
cesivi:
image: cesivi:latest
volumes:
- ./MockData:/app/@MockData
- ./exports:/app/@MockData/.exports # Persistent exports
ports:
- "5000:5000"
Backup Script:
# Trigger export via API
docker compose exec cesivi curl -X POST http://localhost/_api/admin/storage/export \
-H "Content-Type: application/json" -d '{}'
# Exports automatically saved to ./exports on host
ls -lh ./exports/
Troubleshooting¶
Export Issues¶
Problem: Export file is empty or corrupted
Solutions:
# 1. Check storage statistics
curl http://localhost:5000/_api/admin/storage/statistics
# 2. Try with no compression
curl -X POST http://localhost:5000/_api/admin/storage/export \
-H "Content-Type: application/json" \
-d '{"compressionLevel": 0}'
# 3. Verify disk space
df -h
Problem: Export takes too long
Solutions:
# Use lower compression
curl -X POST http://localhost:5000/_api/admin/storage/export \
-H "Content-Type: application/json" \
-d '{"compressionLevel": 3}'
# Exclude files
curl -X POST http://localhost:5000/_api/admin/storage/export \
-H "Content-Type: application/json" \
-d '{"includeFiles": false}'
Import Issues¶
Problem: Import fails with validation errors
Solutions:
# Check ZIP integrity
unzip -t backup.zip
# Disable validation (use with caution)
curl -X POST http://localhost:5000/_api/admin/storage/import \
-F "file=@backup.zip" \
-F "validateBeforeImport=false"
Problem: Files not overwritten in Merge mode
Solution:
# Enable overwrite
curl -X POST http://localhost:5000/_api/admin/storage/import \
-F "file=@backup.zip" \
-F "mode=merge" \
-F "overwriteExisting=true"
Problem: Upload size exceeded
Solutions:
1. Increase RequestSizeLimit in StorageManagementController.cs
2. Split large exports
3. Exclude files: "includeFiles": false
Performance Issues¶
Export Performance: - Small dataset (<10 MB): ~1 second - Medium dataset (10-100 MB): ~5-10 seconds - Large dataset (>100 MB): ~30-60 seconds
Import Performance: - Small dataset: ~1-2 seconds - Medium dataset: ~10-20 seconds - Large dataset: ~1-2 minutes
Optimization: - Replace mode is faster than Merge (no existence checks) - Lower compression levels export faster - SSD storage improves performance significantly
API Reference¶
Export Endpoint¶
POST /_api/admin/storage/export
Request Body:
{
"includeSiteCollections": true,
"includeLists": true,
"includeFiles": true,
"compressionLevel": 6
}
Response:
{
"success": true,
"filePath": "@MockData/.exports/mockdata-export-20251115-102030.zip",
"fileSize": 15728640,
"siteCollectionCount": 3,
"listCount": 25,
"fileCount": 1234,
"timestamp": "2025-11-15T10:20:30Z"
}
Import Endpoints¶
POST /_api/admin/storage/import (upload file)
Form Data:
- file: ZIP file (multipart/form-data)
- mode: "replace" or "merge"
- createBackup: true/false
- overwriteExisting: true/false
POST /_api/admin/storage/import-from-file (from .exports)
Request Body:
{
"fileName": "mockdata-export-20251115-102030.zip",
"options": {
"mode": "Replace",
"createBackup": true
}
}
Management Endpoints¶
GET /_api/admin/storage/exports
- List all available exports
GET /_api/admin/storage/exports/{fileName}
- Download specific export file
DELETE /_api/admin/storage/exports/{fileName}
- Delete export file
GET /_api/admin/storage/statistics
- Get current storage statistics
Best Practices¶
- Always create backups before Replace imports
- Validate exports before deploying to production
- Use Merge mode for incremental updates
- Use Replace mode for complete environment refresh
- Test imports in non-production first
- Monitor file sizes to avoid upload limits
- Clean up old exports regularly
- Document export contents with naming conventions
- Version control critical exports
- Automate regular backups
Related Documentation¶
- Basic Operations - Working with data
- Migration Guide - Import from real SharePoint
- Docker Guide - Container deployment
- API Reference - Complete API docs
Navigation: - ← Usage Guide - Documentation Home
Last Updated: 2025-11-15