Script a Backup with Date

Lets say you have a file or folder that you want to automatically backup. The backups need to have unique names so we will name them based on the date. Use this if you want to automate a backup job that you want to FTP somewhere else or just a simple backup without involving a third party app.

This example is using 7-zip on a Windows platform. I’m sure there are a million ways to do this in Unix.

1. Install 7-zip.

2. Create a new batch file and use the following as a guide.

cd "C:\Program Files\7-Zip"
set dt=%date:~10,4%%date:~4,2%%date:~7,2%
7z a -w C:\Backups\Backup%dt% C:\inetpub\wwwroot
In this example, the backups will go to the C:\Backup directory and be called BackupDate e.g. Backup20100310. In this example we are backing up the IIS directory.

Once you have this batch file written, you can schedule it in task scheduler to run whenever you want. Schedule it daily, monthly, etc.
Script a Backup with Date

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s