Skip to main content

Backup one folder to another location

 You can create a simple batch file (.bat) to back up a folder automatically in Windows. Here’s a step-by-step example:


🔹 Example: Backup one folder to another location

@echo off
set source="C:\MyData"
set destination="D:\Backup\MyData_%date:~-4%-%date:~7,2%-%date:~4,2%"

echo Backing up from %source% to %destination%
xcopy %source% %destination% /E /H /C /I /Y

echo Backup completed!
pause

🔹 Explanation:

  • set source= → Source folder you want to back up.

  • set destination= → Destination folder where backup will be stored.

    • %date:~-4%-%date:~7,2%-%date:~4,2% adds today’s date in YYYY-MM-DD format to the folder name (so each backup is stored separately).

  • xcopy options:

    • /E → Copy all subdirectories (including empty ones).

    • /H → Copy hidden + system files.

    • /C → Continue even if errors occur.

    • /I → Assume destination is a folder.

    • /Y → Suppress overwrite prompts.


🔹 Usage:

  1. Open Notepad.

  2. Paste the code above.

  3. Save it as backup.bat (choose All Files in Save as type).

  4. Double-click backup.bat to run.


Practical Example


Practical Example:2

@echo off

set source="C:\MyData"

set destination="D:\Backup\MyData_%date:~-4%-%date:~7,2%-%date:~4,2%"


echo Backing up from %source% to %destination%

xcopy %source% %destination% /E /H /C /I /Y


echo Backup completed!

pause


Comments

Popular posts from this blog

Creating a Student Marksheet using Microsoft Excel.

 Creating a Student Marksheet using Microsoft Excel.  Creating a student marks sheet in MS Excel is straightforward. Here's a step-by-step guide to design one: Step 1: Open MS Excel Launch MS Excel and open a new workbook. Step 2: Structure the Sheet Header Section: Use the first few rows to include the title, such as "Student Marks Sheet" and relevant details like the class, semester, or term. Column Headings: In Row 5 (or below the title), define your column headers: Column A: Roll Number Column B: Student Name Column C onward: Subjects (e.g., Mathematics, Science, English, etc.) Final Columns: Include Total Marks , Percentage , and Grade . Example: Roll No.Student Name Mathematics Science English Total Marks Percentage Grade Step 3: Input Data Enter the roll numbers, student names, and their marks under respective columns. Step 4: Add Formulas Total Marks: In the "Total Marks" column, use the formula to sum marks: =SUM(C2:E2) Copy this ...

How to create a simple Shopping App with PHP AJAX MYSQL?

  Below is the complete code for the PHP, MySQL, and AJAX-based shopping cart application with features like adding products to the cart, updating cart quantities, and checkout with Cash on Delivery (COD). This includes all the necessary files and steps to set up the application. --- 1. Database Setup Run the following SQL queries to create the database and tables: ```sql CREATE DATABASE shopping_cart; USE shopping_cart; -- Products table CREATE TABLE products (     id INT AUTO_INCREMENT PRIMARY KEY,     name VARCHAR(255) NOT NULL,     price DECIMAL(10, 2) NOT NULL,     description TEXT,     image VARCHAR(255) ); -- Orders table CREATE TABLE orders (     id INT AUTO_INCREMENT PRIMARY KEY,     customer_name VARCHAR(255) NOT NULL,     customer_email VARCHAR(255) NOT NULL,     customer_address TEXT NOT NULL,     total_amount DECIMAL(10, 2) NOT NULL,     status ENUM('pending', ...