Skip to content

Instantly share code, notes, and snippets.

@elico
Last active January 14, 2026 17:38
Show Gist options
  • Select an option

  • Save elico/d66ca33094bf3eb599d413fc1aa9e327 to your computer and use it in GitHub Desktop.

Select an option

Save elico/d66ca33094bf3eb599d413fc1aa9e327 to your computer and use it in GitHub Desktop.
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
# --- Create the Form ---
$Form = New-Object System.Windows.Forms.Form
$Form.Text = "Rclone Sync Setup"
$Form.Size = New-Object System.Drawing.Size(350, 400)
$Form.StartPosition = "CenterScreen"
$Form.Topmost = $true
# IP Address
$LabelIP = New-Object System.Windows.Forms.Label
$LabelIP.Text = "Mobile IP Address:"
$LabelIP.Location = New-Object System.Drawing.Point(20, 20); $LabelIP.Width = 250
$Form.Controls.Add($LabelIP)
$TextIP = New-Object System.Windows.Forms.TextBox
$TextIP.Text = "192.168.231.100"
$TextIP.Location = New-Object System.Drawing.Point(20, 40); $TextIP.Width = 280
$Form.Controls.Add($TextIP)
# Port
$LabelPort = New-Object System.Windows.Forms.Label
$LabelPort.Text = "FTP Port:"
$LabelPort.Location = New-Object System.Drawing.Point(20, 75)
$Form.Controls.Add($LabelPort)
$TextPort = New-Object System.Windows.Forms.TextBox
$TextPort.Text = "6060"
$TextPort.Location = New-Object System.Drawing.Point(20, 95); $TextPort.Width = 280
$Form.Controls.Add($TextPort)
# Password
$LabelPass = New-Object System.Windows.Forms.Label
$LabelPass.Text = "Password:"
$LabelPass.Location = New-Object System.Drawing.Point(20, 130)
$Form.Controls.Add($LabelPass)
$TextPass = New-Object System.Windows.Forms.TextBox
$TextPass.PasswordChar = '*'
$TextPass.Location = New-Object System.Drawing.Point(20, 150); $TextPass.Width = 280
$Form.Controls.Add($TextPass)
# Destination Folder Selection
$LabelDest = New-Object System.Windows.Forms.Label
$LabelDest.Text = "Backup Destination:"
$LabelDest.Location = New-Object System.Drawing.Point(20, 185)
$Form.Controls.Add($LabelDest)
# --- CHANGED: Set default to User Profile folder ---
$DefaultPath = Join-Path $env:USERPROFILE "MobileBackup"
$TextDest = New-Object System.Windows.Forms.TextBox
$TextDest.Text = $DefaultPath
$TextDest.Location = New-Object System.Drawing.Point(20, 205); $TextDest.Width = 200
$TextDest.ReadOnly = $true
$Form.Controls.Add($TextDest)
$BtnBrowse = New-Object System.Windows.Forms.Button
$BtnBrowse.Text = "Browse..."
$BtnBrowse.Location = New-Object System.Drawing.Point(225, 203); $BtnBrowse.Width = 75
$BtnBrowse.Add_Click({
$FolderBrowser = New-Object System.Windows.Forms.FolderBrowserDialog
$FolderBrowser.SelectedPath = $TextDest.Text
$FolderBrowser.Description = "Select the root folder for your mobile backup"
if ($FolderBrowser.ShowDialog() -eq [System.Windows.Forms.DialogResult]::OK) {
$TextDest.Text = $FolderBrowser.SelectedPath
}
})
$Form.Controls.Add($BtnBrowse)
# Start Button
$StartButton = New-Object System.Windows.Forms.Button
$StartButton.Text = "🚀 Start Sync"
$StartButton.Location = New-Object System.Drawing.Point(20, 260); $StartButton.Width = 280; $StartButton.Height = 40
$StartButton.BackColor = "LightGreen"
$StartButton.DialogResult = [System.Windows.Forms.DialogResult]::OK
$Form.Controls.Add($StartButton)
# --- Process Results ---
if ($Form.ShowDialog() -eq [System.Windows.Forms.DialogResult]::OK) {
$RemoteName = "redmi"
$HostIP = $TextIP.Text
$Port = $TextPort.Text
$Pass = $TextPass.Text
$LocalBase = $TextDest.Text
$User = "pc"
$FoldersToSync = @{
"/device/DCIM" = "DCIM"
"/device/Documents" = "Documents"
"/device/Pictures" = "Pictures"
"/device/Android/media/com.whatsapp/WhatsApp/Media" = "WhatsApp-Media"
}
Write-Host "Configuring Rclone..." -ForegroundColor Cyan
rclone config update $RemoteName ftp host=$HostIP port=$Port user=$User pass=$Pass
foreach ($Folder in $FoldersToSync.GetEnumerator()) {
$RemotePath = "$($RemoteName):$($Folder.Key)"
$Destination = Join-Path $LocalBase $Folder.Value
if (!(Test-Path $Destination)) {
New-Item -ItemType Directory -Path $Destination -Force | Out-Null
}
Write-Host "Syncing $($Folder.Key) to $Destination..." -ForegroundColor Yellow
# Added --ignore-errors to prevent one failed folder from stopping the whole script
rclone copy $RemotePath $Destination --progress --ignore-errors
}
Write-Host "`nAll sync tasks finished successfully!" -ForegroundColor Green
Pause
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment