Clash Configuration Backup and Migration: Keep Your Settings When Switching Devices

2026-07-26 10 min read Tutorial

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:

Configuration Items You May Have Invested Heavily In
  • 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

Config Directories for Each Client
  • 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

Android

Linux

Quick Location Tip

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:

Backup Checklist
  • 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 .yaml or .mrs format rule sets), they need to be backed up together.
  • GeoIP database: Files like Country.mmdb or GeoLite2-ASN.mmdb.
  • Cache files (optional): cache.db contains 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.
What Does NOT Need Backing Up

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

Windows Steps
  1. Close the Clash client (ensure it is fully quit, not just minimized)
  2. Open File Explorer and navigate to the config directory (e.g., C:\Users\YourName\.config\clash\)
  3. Select the entire clash folder
  4. Copy it to your desired backup location (USB drive, cloud storage, another folder, etc.)
  5. Consider renaming with a date, such as clash-backup-20260726
macOS/Linux Steps
  1. Close the Clash client
  2. Open Terminal
  3. 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:

Recommended Approach

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

Setup Steps
  1. 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"
Add to Task Scheduler
  1. Open "Task Scheduler" (search for "task" to find it)
  2. Create Basic Task → Name it "Clash Config Backup"
  3. Trigger: Daily → Set a time (e.g., 2:00 AM)
  4. Action: Start a program → Select your backup script
  5. 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:

Using Nutstore (Jianguoyun)
  1. Install and log in to the Nutstore client
  2. Right-click the config directory (e.g., ~/.config/clash/)
  3. Select "Nutstore → Sync to Nutstore"
  4. Config files will automatically sync to the cloud in real-time
Using OneDrive
  1. Move the config directory into the OneDrive sync folder
  2. Or use OneDrive's "Add folder" feature to include the config directory in sync
  3. Config files will automatically sync to OneDrive cloud
Cloud Sync Considerations

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:

Step 1: Export Configuration on Windows
  1. Close the Clash client
  2. Navigate to the config directory (e.g., C:\Users\YourName\.config\clash\)
  3. Package as a zip file: clash-config-windows.zip
  4. Transfer to Mac via USB, cloud storage, or network
Step 2: Install Clash Client on Mac
  1. Download a Mac Clash client (Clash Verge Rev or FlClash recommended)
  2. Install and run for the first time (let it create the default config directory structure)
  3. Immediately close the client after first run
Step 3: Import Configuration
  1. Unzip the Windows config files
  2. Copy config.yaml to the Mac config directory ~/.config/clash/
  3. Copy external rule files to their corresponding locations if any
  4. Copy Country.mmdb and other database files
  5. Restart the Clash client
Step 4: Platform-Specific Adjustments
  1. Check if port configurations conflict with other applications on Mac
  2. If TUN mode is needed, install additional drivers on Mac (the client usually prompts)
  3. Adjust system proxy settings (the Mac system proxy path differs from Windows)
  4. 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)
Path Difference Warning

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

Method 1: In-App Export
  1. Open the Clash client on the old phone
  2. Go to Settings → Find "Export Config" or "Backup" option
  3. Save the exported file to phone storage
  4. Transfer the file to the new phone (via Bluetooth, file transfer, cloud storage, etc.)
  5. Install the same client on the new phone
  6. Go to Settings → Import Config → Select the transferred backup file
Method 2: Re-import Subscription
  1. Install the Clash client on the new phone
  2. Directly paste your subscription link to import
  3. If your rules were customized locally, you need to manually reconfigure them
  4. If your custom config is hosted remotely (e.g., referenced via URL), it will be fetched automatically
Best Practice

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.

Step 1: Export Clash for Windows Config
  1. Close Clash for Windows
  2. Navigate to C:\Users\YourName\.config\clash\
  3. Copy the entire clash directory as backup
  4. Note the key custom content in config.yaml (rules, policy groups, DNS, etc.)
Step 2: Install and Configure Clash Verge Rev
  1. Download and install Clash Verge Rev from GitHub
  2. On first run, it creates a default config in its own directory
  3. Import your subscription link
Step 3: Migrate Custom Configuration
  1. Clash Verge Rev uses an "Override" mechanism to modify configurations
  2. On the "Profiles" page, click your subscription → Edit → Use "Script Editor" or "Override Editor"
  3. Migrate custom rules, DNS configurations, etc. from Clash for Windows into the override config

Configuration Migration Reference

CFW to Verge Rev Configuration Mapping
  • 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 mixin feature → 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:

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
Cloud Sync Pitfall

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:

Git Config Management Steps
  1. Create a private Git repository (GitHub/GitLab private repo)
  2. Initialize Clash config files in the repository
  3. Clone the repository on each device and create symlinks to the config directory
  4. 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:

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:

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:

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:

Solution: Enable TUN mode to capture all traffic. Or configure per-app proxy on the new platform (Android supports this).

Post-Migration Checklist
  • 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