"And when they ask us what we're doing,
you can say, We're remembering.
That's where we'll win out in the long run."
-- Ray Bradbury (Fahrenheit 451)
Cross post from my blog.
Have you ever deleted a file and two days later needed to download it again? Have you ever done this with files that take forever to re-download? Me too...
Create automated backups of your downloaded files.
This sounds like it could be cumbersome and resource-intensive. However, I recently discovered BorgBackup (Borg) and it was neither.
The following commands are set up for Ubuntu 18.04 but should translate to any major operating system without too much hassle.
- Create a directory.
- Install Borg.
sudo apt install borgbackup -y
- Create the repository.
borg init --encryption none bkp/
- Add crons job taking backups and cleaning up old ones.
Using your text editor, add the following lines:
0 12 * * * borg create ~/bkp::Downloads-$(date '+\%m-\%d-\%Y') ~/Downloads/ 0 13 * * * borg prune -v --list --keep-within=7d ~/bkp
When extracting files using Borg, the directory structure in the backup will be the true system path of the directory that you backed up. For this reason, you must specify the system path when extracting the backup to a folder other than the source folder. For example:
borg extract ../bkp::Downloads-09-05-2020 home/e/Downloads
On my system, this command extracts the Dowloads backup from September 5th to the current directory. However, your username probably won't be the letter
Borg has a lot of in-depth and well-developed features outside the scope of this use case. I look forward to setting up some more complex scenarios and creating more walkthroughs in the future. Hopefully, this helps you get started.