Clash Configuration Backup and Migration: Keep Your Settings When Switching Devices
Table of Contents
- Why You Need to Back Up Clash Configuration
- Configuration File Locations (All Platforms)
- What Needs to Be Backed Up
- Manual Backup Methods
- Automatic Backup Solutions
- Cross-Platform Migration: Windows to Mac
- Cross-Platform Migration: Phone to New Phone
- Migrating from Clash for Windows to Clash Verge Rev
- Multi-Device Configuration Sync Solutions
- Common Migration Issues and Solutions
The Clash rules, DNS settings, and policy groups you spent hours carefully configuring can be devastating if lost due to switching computers, reinstalling the system, or a client update. Many users face this situation and have to start from scratch, wasting significant time and effort.
This tutorial systematically covers Clash configuration backup and migration methods, enabling you to quickly restore your working environment in any situation.
Why You Need to Back Up Clash Configuration
A Clash configuration is much more than just a subscription link. An experienced user typically invests considerable effort into:
- Custom rules: Which sites go through the proxy and which connect directly. These rules are progressively refined based on your actual needs
- DNS configuration: Anti-pollution DNS, Fake-IP settings, domain resolution strategies. Misconfiguration can cause various issues
- Policy groups: Structures set up for different scenarios
- Local overrides: Adjustments specific to particular clients
- External configuration references: Referenced rule sets, IP sets, and other external resources
- Client preferences: Port numbers, log levels, TUN mode settings, etc.
Once lost, even if you remember the general approach, reconfiguration takes significant time. Worse yet, if you forget certain details, subtle network issues may become difficult to troubleshoot.
Configuration File Locations (All Platforms)
Different clients store configuration files in different locations. You need to find them before backing up:
Windows
- Clash for Windows:
C:\Users\YourName\.config\clash\ - Clash Verge Rev:
C:\Users\YourName\.local\share\io.github.clash-verge-rev.clash-verge-rev\ - FlClash:
C:\Users\YourName\.config\flclash\
macOS
- ClashX / ClashX Pro:
~/.config/clash/ - Clash Verge Rev:
~/Library/Application Support/io.github.clash-verge-rev.clash-verge-rev/ - FlClash:
~/.config/flclash/
Android
- Clash for Android:
/sdcard/Android/data/com.github.kr328.clash/files/or export via the app - Clash Meta for Android:
/sdcard/Android/data/com.github.metacubex.clash.meta/files/
Linux
- Clash (general):
~/.config/clash/ - Clash Verge Rev:
~/.local/share/io.github.clash-verge-rev.clash-verge-rev/
If you are unsure where the config directory is, check the client's settings page. Most clients display the current config directory path in their settings. In Clash Verge Rev, go to "Settings → Clash Core → Config Directory" to see and open it directly.
What Needs to Be Backed Up
A complete backup should include the following:
- config.yaml: The main configuration file containing all rules, policy groups, proxies, DNS, and other core settings. This is the most important file.
- Subscription profiles: Your imported subscription configurations, typically stored in the
profiles/directory. - Rule files: If you use external rule files (in
.yamlor.mrsformat rule sets), they need to be backed up together. - GeoIP database: Files like
Country.mmdborGeoLite2-ASN.mmdb. - Cache files (optional):
cache.dbcontains DNS cache and Fake-IP mappings. Not backing it up does not affect functionality, but the cache needs to be rebuilt after restoration. - Client settings (optional): Client-specific setting files, such as Clash Verge Rev's
verge.yaml.
The following files do not need to be backed up and can be regenerated or re-downloaded on new devices: - Log files (logs directory) - Temporary files - Expired cache data
Manual Backup Methods
Method 1: Copy the Entire Config Directory
- Close the Clash client (ensure it is fully quit, not just minimized)
- Open File Explorer and navigate to the config directory (e.g.,
C:\Users\YourName\.config\clash\) - Select the entire
clashfolder - Copy it to your desired backup location (USB drive, cloud storage, another folder, etc.)
- Consider renaming with a date, such as
clash-backup-20260726
- Close the Clash client
- Open Terminal
- Execute the copy command:
# Back up the entire config directory
cp -r ~/.config/clash/ ~/Desktop/clash-backup-20260726/
# Or package as a compressed file
tar -czf ~/Desktop/clash-backup-20260726.tar.gz ~/.config/clash/
Method 2: Use Built-in Export Feature
Some clients provide built-in export functionality:
- Clash Verge Rev: Settings → Backup & Restore → Export Config (generates a backup file containing all settings)
- Clash for Android: Settings → Export Config (generates an importable config file)
- Clash Meta for Android: Same as above, find the export option in settings
Built-in export features package all relevant configurations and are less likely to miss files than manual copying. Use built-in export as your primary method, with manual directory copying as a fallback.
Automatic Backup Solutions
Solution 1: Scheduled Tasks + Local Backup
Use system scheduled tasks to regularly back up the config directory to a specified location:
Windows: Using Task Scheduler
- Create a backup script
backup-clash.bat:
@echo off
set SOURCE=C:\Users\YourName\.config\clash
set BACKUP=D:\Backup\clash
set DATE=%date:~0,4%%date:~5,2%%date:~8,2%
xcopy /E /I /Y "%SOURCE%" "%BACKUP%\clash-backup-%DATE%"
echo Backup completed at %DATE% >> "%BACKUP%\backup-log.txt"
- Open "Task Scheduler" (search for "task" to find it)
- Create Basic Task → Name it "Clash Config Backup"
- Trigger: Daily → Set a time (e.g., 2:00 AM)
- Action: Start a program → Select your backup script
- Complete the creation
macOS/Linux: Using cron
# Edit crontab
crontab -e
# Add the following line (backup at 2:00 AM daily)
0 2 * * * cp -r ~/.config/clash/ ~/Backup/clash-backup-$(date +\%Y\%m\%d)/
# Or use a more robust rsync solution
0 2 * * * rsync -av --delete ~/.config/clash/ ~/Backup/clash-latest/
Solution 2: Cloud Sync (Recommended)
Use cloud sync tools (like Nutstore/Jianguoyun, OneDrive, Dropbox) to sync the config directory:
- Install and log in to the Nutstore client
- Right-click the config directory (e.g.,
~/.config/clash/) - Select "Nutstore → Sync to Nutstore"
- Config files will automatically sync to the cloud in real-time
- Move the config directory into the OneDrive sync folder
- Or use OneDrive's "Add folder" feature to include the config directory in sync
- Config files will automatically sync to OneDrive cloud
If your config files contain sensitive information such as proxy server passwords, use encrypted cloud storage or encrypt backup files before uploading. Also, avoid editing the same synced config file simultaneously on multiple devices, as this may cause conflicts.
Cross-Platform Migration: Windows to Mac
Migrating from Windows to Mac is one of the most common cross-platform migration scenarios. Here are the detailed steps:
- Close the Clash client
- Navigate to the config directory (e.g.,
C:\Users\YourName\.config\clash\) - Package as a zip file:
clash-config-windows.zip - Transfer to Mac via USB, cloud storage, or network
- Download a Mac Clash client (Clash Verge Rev or FlClash recommended)
- Install and run for the first time (let it create the default config directory structure)
- Immediately close the client after first run
- Unzip the Windows config files
- Copy
config.yamlto the Mac config directory~/.config/clash/ - Copy external rule files to their corresponding locations if any
- Copy
Country.mmdband other database files - Restart the Clash client
- Check if port configurations conflict with other applications on Mac
- If TUN mode is needed, install additional drivers on Mac (the client usually prompts)
- Adjust system proxy settings (the Mac system proxy path differs from Windows)
- Reconfigure auto-start on boot
Platform Differences to Note
| Setting | Windows | macOS |
|---|---|---|
| Config directory | ~\.config\clash\ |
~/.config/clash/ |
| TUN mode | Requires admin privileges | Requires utun driver installation |
| System proxy | Set via registry | Set via Network preferences |
| Path separator | \ (backslash) |
/ (forward slash) |
If your config.yaml uses absolute paths to reference rule files or other resources, you need to modify the paths after migration. It is recommended to always use relative paths or ~ (home directory) references so cross-platform migration requires no modifications.
Cross-Platform Migration: Phone to New Phone
Android to Android
- Open the Clash client on the old phone
- Go to Settings → Find "Export Config" or "Backup" option
- Save the exported file to phone storage
- Transfer the file to the new phone (via Bluetooth, file transfer, cloud storage, etc.)
- Install the same client on the new phone
- Go to Settings → Import Config → Select the transferred backup file
- Install the Clash client on the new phone
- Directly paste your subscription link to import
- If your rules were customized locally, you need to manually reconfigure them
- If your custom config is hosted remotely (e.g., referenced via URL), it will be fetched automatically
Host your custom rules and configurations on a remote server (such as GitHub Gist) and reference them in Clash via URL. When switching devices, you only need to import one URL and all configurations are fetched automatically, with no manual migration required.
Migrating from Clash for Windows to Clash Verge Rev
Since Clash for Windows has been discontinued, more users are migrating to Clash Verge Rev. While both are based on the Clash core, there are some configuration format differences.
- Close Clash for Windows
- Navigate to
C:\Users\YourName\.config\clash\ - Copy the entire
clashdirectory as backup - Note the key custom content in
config.yaml(rules, policy groups, DNS, etc.)
- Download and install Clash Verge Rev from GitHub
- On first run, it creates a default config in its own directory
- Import your subscription link
- Clash Verge Rev uses an "Override" mechanism to modify configurations
- On the "Profiles" page, click your subscription → Edit → Use "Script Editor" or "Override Editor"
- Migrate custom rules, DNS configurations, etc. from Clash for Windows into the override config
Configuration Migration Reference
- System Proxy toggle: CFW main interface → Verge Rev main interface "System Proxy" toggle
- TUN Mode: CFW's
enable-tun: true→ Verge Rev's TUN mode toggle - Mixin config: CFW's
mixinfeature → Verge Rev's "Override" feature - Profiles: CFW's config file management → Verge Rev's "Profiles" page
- Script: CFW's preprocessing scripts → Verge Rev's "Script" feature (supports JavaScript/Lua)
# Verge Rev Override Example (YAML format)
# Used to append custom content on top of subscription config
prepend-rules:
- "DOMAIN-SUFFIX,google.com,Proxy"
- "DOMAIN-SUFFIX,youtube.com,Proxy"
prepend-proxies:
- name: "Custom Node"
type: vmess
server: example.com
port: 443
uuid: your-uuid
alterId: 0
cipher: auto
mixin-config:
dns:
enable: true
enhanced-mode: fake-ip
nameserver:
- 223.5.5.5
- 119.29.29.29
fallback:
- tls://8.8.8.8:853
Multi-Device Configuration Sync Solutions
Solution 1: Remote Config + Local Override
This is the most recommended multi-device sync approach:
# Core configuration hosted on a remote server (GitHub Gist / self-hosted)
# Referenced via subscription link
proxy-providers:
my-sub:
type: http
url: "https://your-server.com/config.yaml"
interval: 3600
path: ./proxy-providers/my-sub.yaml
# Local override only contains device-specific settings
# Such as port number, TUN mode toggle, etc.
How it works:
- Core rules, policy groups, and proxy information are stored in the remote config, shared by all devices
- Each device's local override contains only that device's specific settings (port, TUN mode, etc.)
- When the remote config is updated, all devices automatically receive the latest configuration
Solution 2: Cloud Drive Sync
Use cloud drive sync for the config directory, suitable for personal multi-device use:
# Example directory structure
CloudDrive/
└── clash-config/
├── config.yaml # Main config
├── rules/ # Rule files
│ ├── proxy-rules.yaml
│ └── direct-rules.yaml
├── verge.yaml # Verge Rev device settings (different per device)
└── README.md # Documentation
Different devices may have different client settings (port numbers, TUN mode toggle, etc.). If you sync the entire config directory directly, changes on one device will affect all devices. It is recommended to separate "shared configuration" from "device-specific configuration".
Solution 3: Git Management (Advanced)
For technical users, using Git to manage configurations is the most powerful approach:
- Create a private Git repository (GitHub/GitLab private repo)
- Initialize Clash config files in the repository
- Clone the repository on each device and create symlinks to the config directory
- After modifying config, commit + push. Other devices pull to get updates
# Create symlink on Linux/Mac
# First back up the original config directory
mv ~/.config/clash ~/.config/clash.bak
# Create symlink pointing to Git repository
ln -s ~/Projects/clash-config ~/.config/clash
# Sync updates
cd ~/Projects/clash-config && git pull
Common Migration Issues and Solutions
Issue 1: All Nodes Timeout After Migration
Possible causes:
- Subscription link needs to be re-imported (some clients bind subscriptions to device identifiers)
- DNS configuration is incompatible with the new platform
- Firewall rules differ, blocking ports
Solution: Manually update the subscription. Check if DNS configuration needs platform-specific adjustments. Confirm ports are not blocked by the local firewall.
Issue 2: Rules Not Working
Possible causes:
- External rule file paths are incorrect
- Rule set files (.mrs/.yaml) were not migrated together
- Different core versions may not support certain rule syntax
Solution: Verify all external file reference paths are correct. Ensure rule set files have been fully migrated. Check logs for rule parsing errors.
Issue 3: TUN Mode Not Working
Possible causes:
- New platform lacks necessary drivers or permissions
- macOS requires additional utun driver installation
- Linux requires setting capabilities
Solution: Set up the TUN mode environment as required by the new platform. See our TUN Mode Configuration Guide for details.
Issue 4: Some Applications Not Going Through Proxy
Possible causes:
- New platform's system proxy mechanism differs
- Some applications do not respect system proxy settings
- TUN mode is not enabled
Solution: Enable TUN mode to capture all traffic. Or configure per-app proxy on the new platform (Android supports this).
- Confirm all nodes can connect normally
- Confirm rule mode routes domestic sites directly and foreign sites through proxy
- Confirm DNS resolution works correctly (no leaks)
- Confirm required applications go through the proxy
- Confirm TUN mode works correctly (if used)
- Confirm auto-start on boot is configured