1- # Required Telegram API credentials
1+ # ==============================================================================
2+ # Telegram Archive — Environment Variables
3+ # ==============================================================================
4+ # Copy this file to .env and fill in your values:
5+ # cp .env.example .env
6+ #
7+ # For the full reference table, see the README:
8+ # https://github.com/GeiserX/Telegram-Archive#environment-variables
9+ # ==============================================================================
10+
11+ # ==============================================================================
12+ # TELEGRAM CREDENTIALS (required for backup)
13+ # ==============================================================================
214# Get these from https://my.telegram.org/apps
315TELEGRAM_API_ID = your_api_id_here
416TELEGRAM_API_HASH = your_api_hash_here
517TELEGRAM_PHONE = +1234567890
618
7- # Backup schedule (cron format: minute hour day month weekday)
8- # Examples:
9- # 0 */6 * * * = Every 6 hours
10- # 0 0 * * * = Daily at midnight
11- # 0 */1 * * * = Every hour
19+ # ==============================================================================
20+ # BACKUP SCHEDULE & STORAGE
21+ # ==============================================================================
22+
23+ # Cron schedule (minute hour day month weekday)
24+ # Examples: 0 */6 * * * (every 6h), 0 0 * * * (daily), 0 */1 * * * (hourly)
1225SCHEDULE = 0 */6 * * *
1326
1427# Backup destination path (inside container)
@@ -22,116 +35,94 @@ DOWNLOAD_MEDIA=true
2235# Files larger than this will be skipped
2336MAX_MEDIA_SIZE_MB = 4096
2437
25- # Batch size for database insertions and progress logging
26- # Higher values = faster but more memory usage
27- # Default: 100
28- # Batch size for database insertions and progress logging
38+ # Messages processed per database batch
2939# Higher values = faster but more memory usage
30- # Default: 100
3140BATCH_SIZE = 100
3241
33- # Sync deletions and edits (Optional)
34- # Set to true to mirror deletions and edits from Telegram
35- # WARNING: This is expensive and slow as it checks every message
36- # Default: false
37- SYNC_DELETIONS_EDITS = false
42+ # Use symlinks to deduplicate identical media files across chats
43+ # DEDUPLICATE_MEDIA=true
3844
39- # Media verification mode (Optional)
40- # When enabled, checks all media files on disk after each backup
41- # Re-downloads any missing or corrupted files from Telegram
42- # Useful for recovering from interrupted backups or accidentally deleted media
43- # Default: false
44- VERIFY_MEDIA = false
45+ # Comma-separated chat IDs to process FIRST in all operations
46+ # PRIORITY_CHAT_IDS=
47+
48+ # Hour (0-23) to recalculate backup statistics daily
49+ # STATS_CALCULATION_HOUR=3
50+
51+ # Logging level: DEBUG, INFO, WARNING, ERROR
52+ LOG_LEVEL = INFO
53+
54+ # Session name (use different names for multiple accounts)
55+ SESSION_NAME = telegram_backup
56+
57+ # Session directory (defaults to /data/session)
58+ # SESSION_DIR=/data/session
4559
4660# ==============================================================================
47- # CHAT FILTERING - Choose ONE mode
61+ # CHAT FILTERING — Choose ONE mode
4862# ==============================================================================
4963
50- # -----------------------------------------------------------------------------
51- # MODE 1: WHITELIST (Simple) - Set CHAT_IDS to backup ONLY specific chats
52- # -----------------------------------------------------------------------------
53- # When set, ONLY these chats are backed up. All other settings are ignored.
64+ # MODE 1: WHITELIST (Simple) — Set CHAT_IDS to backup ONLY specific chats
65+ # When set, ONLY these chats are backed up. All other filtering is ignored.
5466# Example: CHAT_IDS=-1001234567890,-1009876543210
5567CHAT_IDS =
5668
57- # -----------------------------------------------------------------------------
58- # MODE 2: TYPE-BASED (Default) - Use CHAT_TYPES to backup by type
59- # -----------------------------------------------------------------------------
69+ # MODE 2: TYPE-BASED (Default) — Use CHAT_TYPES to backup by type
6070# Options: private, groups, channels (comma-separated)
61- # Example: CHAT_TYPES=private,groups (everything except channels)
6271CHAT_TYPES = private,groups,channels
6372
64- # EXCLUDE specific chats (blacklist - takes priority)
73+ # EXCLUDE specific chats (blacklist — takes priority)
6574GLOBAL_EXCLUDE_CHAT_IDS =
6675PRIVATE_EXCLUDE_CHAT_IDS =
6776GROUPS_EXCLUDE_CHAT_IDS =
6877CHANNELS_EXCLUDE_CHAT_IDS =
6978
70- # INCLUDE additional chats (additive - adds to what CHAT_TYPES already includes )
79+ # INCLUDE additional chats (additive — adds to what CHAT_TYPES selects )
7180# Note: These ADD to the selection, they don't restrict it.
7281# For exclusive selection, use CHAT_IDS mode instead.
7382GLOBAL_INCLUDE_CHAT_IDS =
7483PRIVATE_INCLUDE_CHAT_IDS =
7584GROUPS_INCLUDE_CHAT_IDS =
7685CHANNELS_INCLUDE_CHAT_IDS =
7786
78- # Examples:
79- # 1. Backup ONLY these 2 channels (nothing else):
80- # CHAT_IDS=-1001234567890,-1009876543210
81- #
82- # 2. Backup all groups except one:
83- # CHAT_TYPES=groups
84- # GROUPS_EXCLUDE_CHAT_IDS=-123456789
85- #
86- # 3. Backup all groups PLUS one specific channel:
87- # CHAT_TYPES=groups
88- # CHANNELS_INCLUDE_CHAT_IDS=-1001234567890
87+ # ==============================================================================
88+ # REAL-TIME LISTENER
89+ # ==============================================================================
90+ # ENABLE_LISTENER is the master switch. When false (default), all LISTEN_*
91+ # and MASS_OPERATION_* variables below have no effect.
8992
93+ ENABLE_LISTENER = false
9094
91- # Logging level
92- # Options: DEBUG, INFO, WARNING, ERROR
93- LOG_LEVEL = INFO
95+ # Granular listener controls (only apply when ENABLE_LISTENER=true):
96+ # LISTEN_EDITS=true
97+ # LISTEN_DELETIONS=true
98+ # LISTEN_NEW_MESSAGES=true
99+ # LISTEN_NEW_MESSAGES_MEDIA=false
100+ # LISTEN_CHAT_ACTIONS=true
94101
95- # Session name (for multiple accounts, use different names)
96- SESSION_NAME = telegram_backup
102+ # Mass operation protection (only applies when ENABLE_LISTENER=true)
103+ # MASS_OPERATION_THRESHOLD=10
104+ # MASS_OPERATION_WINDOW_SECONDS=30
105+ # MASS_OPERATION_BUFFER_DELAY=2.0
97106
98- # Session directory (defaults to /data/session)
99- # The session file is stored separately from backup data for better organization
100- # SESSION_DIR=/data/session
107+ # Batch sync alternative (expensive — prefer ENABLE_LISTENER instead)
108+ SYNC_DELETIONS_EDITS = false
101109
102- # Database directory (optional)
103- # Store the SQLite database in a separate location (e.g., on SSD)
104- # Default: same as BACKUP_PATH
105- # DATABASE_DIR=/data/database
110+ # Re-download missing or corrupted media files
111+ VERIFY_MEDIA = false
106112
107- # ================================
108- # Display Chat IDs (Viewer Restriction)
109- # ================================
110- # Restrict the web viewer to show only specific chats
111- # Useful for sharing public channel viewers without exposing other chats
112- # Comma-separated list of chat IDs (e.g., 224091347,-100123456789)
113- # DISPLAY_CHAT_IDS=
113+ # ==============================================================================
114+ # DATABASE CONFIGURATION (v3.0+)
115+ # ==============================================================================
116+ # Supports SQLite (default) and PostgreSQL.
117+ # Both backup and viewer containers MUST use the same database settings.
114118
115- # ================================
116- # Database Configuration (v3.0+)
117- # ================================
118- # Telegram Archive supports multiple database backends:
119- # - SQLite (default): Simple, no setup required
120- # - PostgreSQL: Better for high-traffic deployments
121-
122- # Option 1: Use DATABASE_URL (takes priority)
123- # SQLite example:
124- # DATABASE_URL=sqlite:///data/telegram_backup.db
125- # PostgreSQL example:
126- # DATABASE_URL=postgresql://user:password@localhost:5432/telegram_backup
127-
128- # Option 2: Use individual settings (v2 DATABASE_PATH/DATABASE_DIR also supported)
129- # DB_TYPE: sqlite (default) or postgresql
130- DB_TYPE = sqlite
119+ # Option 1: Full DATABASE_URL (takes priority over all below)
120+ # SQLite: DATABASE_URL=sqlite:///data/telegram_backup.db
121+ # PostgreSQL: DATABASE_URL=postgresql://user:password@localhost:5432/telegram_backup
131122
132- # SQLite settings (when DB_TYPE=sqlite)
133- # DB_PATH: Path to SQLite database file
134- DB_PATH = data/telegram_backup.db
123+ # Option 2: Individual settings
124+ DB_TYPE = sqlite
125+ DB_PATH = / data/backups /telegram_backup.db
135126
136127# PostgreSQL settings (when DB_TYPE=postgresql)
137128# POSTGRES_HOST=localhost
@@ -140,5 +131,48 @@ DB_PATH=data/telegram_backup.db
140131# POSTGRES_PASSWORD=your_secure_password
141132# POSTGRES_DB=telegram_backup
142133
143- # Enable SQL query logging (for debugging)
144- # DB_ECHO=false
134+ # ==============================================================================
135+ # VIEWER & AUTHENTICATION
136+ # ==============================================================================
137+ # These apply to the telegram-archive-viewer container.
138+
139+ # Basic auth — set BOTH to enable authentication (recommended)
140+ # VIEWER_USERNAME=admin
141+ # VIEWER_PASSWORD=your_secure_password
142+ # AUTH_SESSION_DAYS=30
143+
144+ # Timezone for displayed timestamps (tz database name)
145+ # VIEWER_TIMEZONE=Europe/Madrid
146+
147+ # Show backup statistics dropdown in viewer header
148+ # SHOW_STATS=true
149+
150+ # Restrict viewer to specific chats (comma-separated IDs)
151+ # Useful for sharing public channel viewers without exposing other chats
152+ # DISPLAY_CHAT_IDS=
153+
154+ # ==============================================================================
155+ # SECURITY
156+ # ==============================================================================
157+
158+ # Allowed CORS origins (comma-separated)
159+ # Default: * (allow all origins, credentials auto-disabled)
160+ # Example: CORS_ORIGINS=https://my.domain.com,https://other.domain.com
161+ # CORS_ORIGINS=*
162+
163+ # Set Secure flag on auth cookies
164+ # Disable (false) only when developing locally over HTTP
165+ # SECURE_COOKIES=true
166+
167+ # ==============================================================================
168+ # NOTIFICATIONS
169+ # ==============================================================================
170+
171+ # Push notification mode: off, basic (in-browser only), full (Web Push)
172+ # PUSH_NOTIFICATIONS=basic
173+
174+ # Custom VAPID keys for Web Push (auto-generated if empty)
175+ # Generate with: npx web-push generate-vapid-keys
176+ # VAPID_PRIVATE_KEY=
177+ # VAPID_PUBLIC_KEY=
178+ # VAPID_CONTACT=mailto:admin@example.com
0 commit comments