Skip to content

Instantly share code, notes, and snippets.

@AggamR
Created March 26, 2021 15:04
Show Gist options
  • Save AggamR/49161e8e8c297b8d07cbbd75e0df0fba to your computer and use it in GitHub Desktop.
Save AggamR/49161e8e8c297b8d07cbbd75e0df0fba to your computer and use it in GitHub Desktop.
a script to automatically backup all files listed in the `/home/aggam/backups/foldersToBackup` file
#!/bin/bash
[ -d /home/aggam/backups/folders$(date '+%d%B%Y') ] && rm -rf /home/aggam/backups/folders$(date '+%d%B%Y')
while read p; do
echo $p
mkdir /home/aggam/backups/folders$(date '+%d%B%Y')
cp -r $p /home/aggam/backups/folders$(date '+%d%B%Y')
done </home/aggam/backups/foldersToBackup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment