How to backup whatsapp data from pc using window powershell
However, it's crucial to understand what you're backing up. The WhatsApp desktop app is a mirror of your phone. It stores a local cache of your messages, images, and files for quick access. This backup will save that cache, but it is not a substitute for the main backup you should be doing on your phone (to Google Drive or iCloud).
## ⚠️ Important Disclaimer
This is a cache backup: This script backs up the temporary files and data stored on your PC. Your complete, authoritative chat history is on your phone.
Primary Backup: Always ensure your primary WhatsApp backup is active on your mobile device by going to WhatsApp > Settings > Chats > Chat backup.
Restoring: Restoring this PC backup will only bring back the cached data to your desktop app. If you reinstall WhatsApp, it will sync everything fresh from your phone anyway. This backup is most useful if your app becomes corrupted and you want to restore its state without re-downloading everything.
## Step 1: Identify Your WhatsApp Data Folder
WhatsApp on Windows can be installed from two different sources, and the data is stored in different locations. You only need to find the one that exists on your system.
Microsoft Store Version: The path is usually:
C:\Users\<YourUsername>\AppData\Local\Packages\5319275A.WhatsAppDesktop_cv1g1gvanyjgm
Web Installer Version (from WhatsApp.com): The path is usually:
C:\Users\<YourUsername>\AppData\Roaming\WhatsApp
The script below will automatically check for both locations.
## Step 2: The PowerShell Backup Script
This script will automatically detect which version of WhatsApp you have, create a backup folder on your Desktop, and copy all the data into it.
Open a plain text editor like Notepad.
Copy and paste the entire code block below into Notepad.
Save the file to your Desktop as
Backup-WhatsApp.ps1
.
# ===================================================================
# WhatsApp Desktop Data Backup Script
# ===================================================================
# --- CONFIGURATION ---
# Set the destination for your backup.
# The script will create a "WhatsApp Desktop Backup" folder here.
$BackupParentFolder = [System.Environment]::GetFolderPath('Desktop')
# --- SCRIPT LOGIC (No need to edit below this line) ---
# Construct the full path for the backup destination folder
$BackupDestination = Join-Path -Path $BackupParentFolder -ChildPath "WhatsApp Desktop Backup"
# Define the two possible source paths for WhatsApp data
$StoreAppPath = Join-Path -Path $env:LOCALAPPDATA -ChildPath "Packages\5319275A.WhatsAppDesktop_cv1g1gvanyjgm"
$WebAppPath = Join-Path -Path $env:APPDATA -ChildPath "WhatsApp"
$SourcePath = ""
$AppVersion = ""
# Check which version of WhatsApp is installed
if (Test-Path $StoreAppPath) {
$SourcePath = $StoreAppPath
$AppVersion = "Microsoft Store"
}
elseif (Test-Path $WebAppPath) {
$SourcePath = $WebAppPath
$AppVersion = "Web Installer"
}
# If a WhatsApp installation was found, proceed with the backup
if ($SourcePath) {
Write-Host "✅ Found WhatsApp ($AppVersion version) data at: $SourcePath" -ForegroundColor Green
# Create the backup destination folder if it doesn't exist
if (-not (Test-Path $BackupDestination)) {
Write-Host "📂 Creating backup folder at: $BackupDestination"
New-Item -ItemType Directory -Path $BackupDestination | Out-Null
} else {
Write-Host "📂 Backup folder already exists at: $BackupDestination"
}
Write-Host "⏳ Starting backup... This might take a while depending on the data size."
# Copy the data recursively, overwriting files if they exist, and show progress
try {
Copy-Item -Path "$SourcePath\*" -Destination $BackupDestination -Recurse -Force -Verbose
Write-Host "🎉 Backup completed successfully!" -ForegroundColor Green
}
catch {
Write-Host "❌ An error occurred during the copy process." -ForegroundColor Red
Write-Host $_.Exception.Message
}
}
else {
# If no WhatsApp folder was found, inform the user
Write-Host "❌ Could not find WhatsApp data folder. Please ensure WhatsApp Desktop is installed." -ForegroundColor Red
}
# Pause the script to allow the user to read the output
Read-Host "Press Enter to exit."
## Step 3: How to Run the Script
You can't just double-click a PowerShell script by default. You need to run it from a PowerShell terminal.
Open PowerShell: Right-click the Start Menu button and select Windows PowerShell or Terminal.
Navigate to the Desktop: Type the following command and press Enter.
PowerShellcd Desktop
Allow Script Execution (One-Time Step): If you've never run PowerShell scripts before, you may need to change the execution policy. This command allows scripts you've created on your computer to run.
PowerShellSet-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
It will ask for confirmation; press Y and then Enter.
Run the Backup Script: Now, run your script by typing its name and pressing Enter.
PowerShell.\Backup-WhatsApp.ps1
You will see the script find your WhatsApp folder and start copying the files. Once it's done, you'll find a folder named WhatsApp Desktop Backup on your desktop containing all the data.