An approach to backing up the current user's HOME, using tar(1) and Gzip compression. Permissions (modes) will be preserved. The filename format will be: UID:GID_DATE.tgz
Replace 'DEVICE' with whichever device is applicable to you, but note that it must be in the /media/USER (where USER is the username) directory, else this won't work, unless you edit the formatting section of printf.
tar -- **exclude**={'*.mp3','*.avi'} '/home/2daygeek/ **demo**/' -zcvpf /backup/2daygeek-backup-$(date +%d-%m-%Y).tar.gz /home/2daygeek
#!/bin/bash
DATE=$(date +%d-%m-%Y)
BACKUP_DIR="/backup"
#To backup 2daygeek's home directory
tar -zcvpf $BACKUP_DIR/$USER-$DATE.tar.gz /home/$USER
#To delete files older than 10 days
find $BACKUP_DIR/* -mtime +10 -exec rm {} \;
tar -zcvpf /[Backup_File_Location]/[Backup_Filename] /[User's_Home_Directory_Location]
z : Compress the backup file with ‘gzip’ to make it small size.
c : Create a new backup archive.
v : verbosely list files which are processed.
p : Preserves the permissions of the files put in the archive for later restoration.
f : use archive file or device ARCHIVE.