# Windows: I want to backup a file, compress every night saving it with a unique title showing the date

**URL:** https://boards.straightdope.com/t/windows-i-want-to-backup-a-file-compress-every-night-saving-it-with-a-unique-title-showing-the-date/1001187
**Category:** Factual Questions
**Created:** [May 6, 2024, 3:15pm UTC](https://boards.straightdope.com/t/windows-i-want-to-backup-a-file-compress-every-night-saving-it-with-a-unique-title-showing-the-date/1001187 "2024-05-06T15:15:40Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![PastTense](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/pasttense/32/14550_2.png) [@PastTense](https://boards.straightdope.com/u/PastTense)
#### Post date: [May 6, 2024, 3:15pm UTC](https://boards.straightdope.com/t/windows-i-want-to-backup-a-file-compress-every-night-saving-it-with-a-unique-title-showing-the-date/1001187/1 "2024-05-06T15:15:40Z")

</div>

[I want a free solution.]

I have a Windows mdb database.  
Every night I wish to run a backup. I wish to compress the database and save it with a unique name consisting of the database name and date.

Is there a problem if the database is open in another application? What happens?

Thanks.

---

<div class="post-metadata">

### Author: ![enipla](https://avatars.discourse-cdn.com/v4/letter/e/54ee81/32.png) [@enipla](https://boards.straightdope.com/u/enipla)
#### Post date: [May 6, 2024, 4:38pm UTC](https://boards.straightdope.com/t/windows-i-want-to-backup-a-file-compress-every-night-saving-it-with-a-unique-title-showing-the-date/1001187/2 "2024-05-06T16:38:27Z")

</div>

I did something like that for my mom.

It was dos commands in a .bat file that was then run with Task Scheduler. I’m sorry I don’t really have time to create that know, and would rather someone else critique that plan before I do.

Shouldn’t be a problem if it’s open. The first move will be to copy and rename. But the copy should put a time stamp on it anyway.

---

<div class="post-metadata">

### Author: ![Stranger\_On\_A\_Train](https://avatars.discourse-cdn.com/v4/letter/s/13edae/32.png) [@Stranger\_On\_A\_Train](https://boards.straightdope.com/u/Stranger_On_A_Train)
#### Post date: [May 6, 2024, 4:44pm UTC](https://boards.straightdope.com/t/windows-i-want-to-backup-a-file-compress-every-night-saving-it-with-a-unique-title-showing-the-date/1001187/3 "2024-05-06T16:44:48Z")

</div>

I’ll refrain from asking why you want to do this and just observe that the best way to perform this, assuming that Access is running, is to schedule an event in a VBA process to perform an export. If it is not running, you can [run Access as in the Task Scheduler](https://stackoverflow.com/questions/20245053/running-microsoft-access-as-a-scheduled-task#20251788) and execute an export routine.

I’m not sure what you mean by “compress the database”; Access has functionality to [_compact and repair_](https://support.microsoft.com/en-us/office/compact-and-repair-a-database-6ee60f16-aed0-40ac-bf22-85fa9f4005b2) the database (which should be done periodically to clean up the database) but this doesn’t compress anything; it just removes residual information. It sounds like you want to export the database to a text format (using SaveAsText) and then zip the text file [via a shell command](https://stackoverflow.com/questions/20245053/running-microsoft-access-as-a-scheduled-task#20251788). This is all kind of clunky, but then that it basically the definition of Access.

Stranger

---

<div class="post-metadata">

### Author: ![wolfpup](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/wolfpup/32/10618_2.png) [@wolfpup](https://boards.straightdope.com/u/wolfpup)
#### Post date: [May 6, 2024, 4:48pm UTC](https://boards.straightdope.com/t/windows-i-want-to-backup-a-file-compress-every-night-saving-it-with-a-unique-title-showing-the-date/1001187/4 "2024-05-06T16:48:33Z")

</div>

Macrium Reflect has a fully functional free version that **might** do what you want, including automatic scheduled backups from an XML script and compression, except that the free version (a) only backs up entire volumes, not specified files, and (b) will do full or differential backups, but not incrementals. File and folder type backups and incremental backups require the paid version.

It will back up files even if they’re open in another application, although obviously there’s no guarantee what that file might or might not contain.

---

<div class="post-metadata">

### Author: ![PastTense](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/pasttense/32/14550_2.png) [@PastTense](https://boards.straightdope.com/u/PastTense)
#### Post date: [May 6, 2024, 5:55pm UTC](https://boards.straightdope.com/t/windows-i-want-to-backup-a-file-compress-every-night-saving-it-with-a-unique-title-showing-the-date/1001187/5 "2024-05-06T17:55:53Z")

</div>

If I run the Compress and Repair Database Utility it compresses the file to 118 MB.

If I right click the file name and select "Send to Compressed (Zipped) Folder it reduces the size to 32 MB, and I can also rename the file at the same time to include the date if I want. So this works fine as a manual process–but I want an automated backup process which runs every night.

As to why I want to do this I just had a problem where the database got badly messed up. And it must happened a few days previously, but I am not sure when. So I want to be able to restore the database from yesterday, look at it. If the data is not correct restore the data from two days ago, look at it and so on.

---

<div class="post-metadata">

### Author: ![Stranger\_On\_A\_Train](https://avatars.discourse-cdn.com/v4/letter/s/13edae/32.png) [@Stranger\_On\_A\_Train](https://boards.straightdope.com/u/Stranger_On_A_Train)
#### Post date: [May 6, 2024, 6:06pm UTC](https://boards.straightdope.com/t/windows-i-want-to-backup-a-file-compress-every-night-saving-it-with-a-unique-title-showing-the-date/1001187/6 "2024-05-06T18:06:19Z")

</div>

> [@PastTense](#):
>
> Compress and Repair Database Utility

_Compact_ and Repair; it doesn’t do any compression; it just removes historical information.

> [@PastTense](#):
>
> If I right click the file name and select "Send to Compressed (Zipped) Folder it reduces the size to 32 MB, and I can also rename the file at the same time to include the date if I want. So this works fine as a manual process–but I want an automated backup process which runs every night.

You should be able to do this using VBA and Windows Task Scheduler as described above. The problem with an external copy is that if Access is running and performing a write operation, you’ll likely end up with a corrupted backup. If you do it within Access (either exporting as text or saving to a separate database file) Access will hold up until the write process is complete.

Stranger

---

<div class="post-metadata">

### Author: ![Shoeless](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/shoeless/32/7099_2.png) [@Shoeless](https://boards.straightdope.com/u/Shoeless)
#### Post date: [May 6, 2024, 10:54pm UTC](https://boards.straightdope.com/t/windows-i-want-to-backup-a-file-compress-every-night-saving-it-with-a-unique-title-showing-the-date/1001187/7 "2024-05-06T22:54:30Z")

</div>

I would use something like 7-Zip rather than the built-in Windows file compression. 7-Zip is free and has a command line utility that you can call from a bat or cmd file to do the file compression. But I would definitely make sure the mdb file is not in use when zipping it. Is it a local file or a shared database on a network?

---

<div class="post-metadata">

### Author: ![PastTense](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/pasttense/32/14550_2.png) [@PastTense](https://boards.straightdope.com/u/PastTense)
#### Post date: [May 6, 2024, 11:57pm UTC](https://boards.straightdope.com/t/windows-i-want-to-backup-a-file-compress-every-night-saving-it-with-a-unique-title-showing-the-date/1001187/8 "2024-05-06T23:57:50Z")

</div>

It’s a local file I manually update a few times a day, so there is no risk of an operation happening in the middle of the night when I am not using the computer.

---

<div class="post-metadata">

### Author: ![PastTense](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/pasttense/32/14550_2.png) [@PastTense](https://boards.straightdope.com/u/PastTense)
#### Post date: [May 7, 2024, 3:00am UTC](https://boards.straightdope.com/t/windows-i-want-to-backup-a-file-compress-every-night-saving-it-with-a-unique-title-showing-the-date/1001187/9 "2024-05-07T03:00:24Z")

</div>

Thanks everyone.

Right now I am looking at Hasleo, a freeware backup imaging program which will backup specified files like the paid version of Macrium Reflect does.

> **[Hasleo provides Windows Backup & Clone, Data Recovery, Windows To Go...](https://www.hasleo.com/)**
>
> Hasleo Software provides Windows Backup & Clone, Data Recovery, Windows To Go Creator, BitLocker solution and other software to help you enrich your digital life.

---

<div class="post-metadata">

### Author: ![LSLGuy](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/lslguy/32/5813_2.png) [@LSLGuy](https://boards.straightdope.com/u/LSLGuy)
#### Post date: [May 7, 2024, 10:15am UTC](https://boards.straightdope.com/t/windows-i-want-to-backup-a-file-compress-every-night-saving-it-with-a-unique-title-showing-the-date/1001187/10 "2024-05-07T10:15:52Z")

</div>

> [@PastTense](#):
>
> It’s a local file I manually update a few times a day, so there is no risk of an operation happening in the middle of the night when I am not using the computer.

I will make the small but utterly vital distinction between “you using the computer”, and “the computer is turned on and Access is a running app and it has that database open”.

When you perform the compact / export / backup process you want to ensure that no copy of Access is running on any machine that can reach your database. Not knowing whether you have one PC at home or 15 I can’t get more specific than that. But if a copy of Access has the database open at the time your copy / backup operation tries to run, you will have problems eventually, and maybe every single time. So don’t do that.

Unrelated to the above. …  
As @Stranger_On_A_Train said, the “compact” operation is, _very_ loosely speaking, about the same as emptying the recycle bin on a disk drive. I would expect that if you compact the database in place, it might go from 118MB to 32. But just once. Tomorrow after some adds and updates it’ll compact from 32.8 to 32.4. etc. If you’re doing a compacted export, so your original isn’t being compacted, just the outgoing copy, _then_ I’d expect the size reduction to happen each time.

---

<div class="post-metadata">

### Author: ![wolfpup](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/wolfpup/32/10618_2.png) [@wolfpup](https://boards.straightdope.com/u/wolfpup)
#### Post date: [May 7, 2024, 10:32am UTC](https://boards.straightdope.com/t/windows-i-want-to-backup-a-file-compress-every-night-saving-it-with-a-unique-title-showing-the-date/1001187/11 "2024-05-07T10:32:16Z")

</div>

> [@wolfpup](#):
>
> Macrium Reflect has a fully functional free version …

I just checked out of curiosity, and Macrium Reflect is no longer free in any edition. Just FYI. If you have the free version, or can get it, it will continue to work, but you can no longer download it from Macrium. This just confirms my view that the world is getting worse in almost every way! 😉

Macrium Reflect was, and remains, really excellent backup software, and I can’t really blame them for discontinuing the free version.

---

<div class="post-metadata">

### Author: ![The\_Librarian](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/the_librarian/32/402_2.png) [@The\_Librarian](https://boards.straightdope.com/u/The_Librarian)
#### Post date: [May 7, 2024, 10:37am UTC](https://boards.straightdope.com/t/windows-i-want-to-backup-a-file-compress-every-night-saving-it-with-a-unique-title-showing-the-date/1001187/12 "2024-05-07T10:37:34Z")

</div>

Make friends with windows’ native backup functionality.

---

<div class="post-metadata">

### Author: ![PastTense](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/pasttense/32/14550_2.png) [@PastTense](https://boards.straightdope.com/u/PastTense)
#### Post date: [May 7, 2024, 12:22pm UTC](https://boards.straightdope.com/t/windows-i-want-to-backup-a-file-compress-every-night-saving-it-with-a-unique-title-showing-the-date/1001187/13 "2024-05-07T12:22:12Z")

</div>

Macrium Free is still available at the traditional download sites which offer downloads of thousands of programs, such as:

> **[Macrium Reflect FREE Edition](https://www.majorgeeks.com/files/details/macrium_reflect_free_edition.html)**
>
> With Macrium Reflect Free Edition you'll be able to easily make an accurate and reliable image of your HDD or individual partitions. Using this image you can restore the entire disk, partition or...

> **[Macrium Reflect Free](https://www.techspot.com/downloads/5442-macrium-reflect-free.html)**
>
> Disk image, file backup and disk cloning for Windows.

> **[Macrium Reflect Free for Windows - Free download and software reviews - CNET...](https://download.cnet.com/macrium-reflect-free/3000-2242_4-10845728.html)**
>
> Download Macrium Reflect Free for Windows to . Macrium Reflect Free has had 7 updates.

But, correct, it is no longer being updated.

---

<div class="post-metadata">

### Author: ![K364](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/k364/32/5_2.png) [@K364](https://boards.straightdope.com/u/K364)
#### Post date: [May 7, 2024, 2:03pm UTC](https://boards.straightdope.com/t/windows-i-want-to-backup-a-file-compress-every-night-saving-it-with-a-unique-title-showing-the-date/1001187/14 "2024-05-07T14:03:55Z")

</div>

You said mdb file, which implies a very old version of Access, so I’m not sure if this is available but an option in Access is to compact and repair when the file is closed, that is when you close the db, or exit Access. That takes care of the compact requirement, and makes better sense since it only executes after you use the file, not over and over again regardless of whether you have done anything to the file.

To copy with a timestamp - [https://shellgeek.com/powershell-move-file-and-rename-with-date/](https://shellgeek.com/powershell-move-file-and-rename-with-date/)

---

<div class="post-metadata">

### Author: ![K364](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/k364/32/5_2.png) [@K364](https://boards.straightdope.com/u/K364)
#### Post date: [May 7, 2024, 2:12pm UTC](https://boards.straightdope.com/t/windows-i-want-to-backup-a-file-compress-every-night-saving-it-with-a-unique-title-showing-the-date/1001187/15 "2024-05-07T14:12:28Z")

</div>

Oh, I see that moves the file, you can use copy-item instead for the copy operation.
