This script creates incremental backups using rsync and manages retention of old backups.
-
Set the
SOURCE_DIRSvariable to specify the directories you want to back up. -
To back up multiple directories, you can simply add them to the
SOURCE_DIRSarray in your script.SOURCE_DIRS=( "/path/to/files-to-be-backup" "/path/to/another-directory" "/path/to/yet-another-directory" ) -
Set the
BACKUP_ROOTvariable to specify the directory where backups will be stored. -
Set the
RETENTION_DAYSvariable to specify how many days of backups you want to keep. Backups older than this period will be automatically deleted the next time the script runs.
- Be careful when setting the
BACKUP_ROOTvariable. If misconfigured, the script could delete important files. - Review the script and customize it for your needs before using it.
-
Make the script executable:
chmod +x backup.sh
-
Run the script:
./backup.sh
This script is provided as is, without warranty of any kind. Use it at your own risk. Review and customize the script before using it.