A few simple scripts for automated data backup
By Zheng Zhang
October 12, 2019
PowerShell on Windows work computer
Work computers within the hospital network typically restrict administrative rights to install custom tools. Over the years, I have found that PowerShell + robocopy nightly backup to an intranet network share is the most straight-forward method.
First create the following PowerShell script and save it as nightly-backup.ps1 under User Home.
ROBOCOPY C:\Workspace \\INTRANET\UserHome\Backup\Workspace /DCOPY:DA /MT /MIR /FFT /Z /XA:SH /R:0 /TEE /XJD
Then create a task in Task Scheduler to be run every midnight. Technically speaking, this is just synchronizing a nightly snapshot, and not a backup. But network shares are an expensive resource, and storing a separately time-stamped snapshot every day makes little sense.
restic on Linux personal computer
In my experience, restic is hands down the best backup utility. On Windows, this can be installed with
scoop. It is packaged with many distros.
First, create a repo with an optional password file
restic init --repo /path/to/repo --password-file /path/to/password-file
Then create a bash script for backing up
#!/usr/bin/env bash
restic -r /path/to/repo --password-file /path/to/password-file --exclude="/path/to/excluded-dirs/*" backup /path/to/original-files
Use anacron to set up regular backup intervals. Place the back up script under ~/.local/etc/cron.daily
- Posted on:
- October 12, 2019
- Length:
- 1 minute read, 188 words
- Tags:
- PowerShell restic backup
- See Also: