rsync syntax help for /home backup

Questions about other topics - please check if your question fits better in another category before posting here
Forum rules
Before you post please read how to get help
Post Reply
chris_debian
Level 2
Level 2
Posts: 93
Joined: Fri Sep 24, 2010 5:14 am

rsync syntax help for /home backup

Post by chris_debian »

Hi, all.

Each month, I backup my /home to an external USB HDD. This works well, but takes a long time. I suspect this is because everything is being copied fresh, each time I perform the operation, when I only need the added and deleted files to be amended. I can confirm that files that have been deleted from my /home are being deleted as part of the rsync back up.

Could I ask anyone who uses rsync to have a look at the command I am using, and see whether it looks correct.

For info, I am executing the command as a user (chris), and I want to back up /home/chris to my Freecom HDD directory, called Backup. I think I am excluding files that begin with a '.'

I am using this:

Code: Select all

rsync -av --delete --exclude=".*/" /home/chris/ /media/chris/FREECOM\ HDD/Backup/


I'd really appreciate a second opinion on this. As I say, the backup completes, it just takes a long time, and most of the contents don't change from one month to the next (photos, music etc).

Cheers,

Chris.
Reasons why you may want to try GNU/Linux:

http://www.whylinuxisbetter.net/
Habitual
Level 13
Level 13
Posts: 4861
Joined: Sun Nov 21, 2010 8:31 pm
Location: 0.0.0.0

Re: rsync syntax help for /home backup

Post by Habitual »

Hey Chris:

That looks alright.
Test it with "rsync -avn" ...

But you may wish to reconsider excluding some of those. ~/.config and ~/.gconf are pretty important. :wink:

Try this: (with -avn first!)

Code: Select all

#!/bin/bash
clear
cd ~
if $(cat /proc/mounts | grep  -i "FREECOM" > /dev/null)  
then
rsync -avz --no-perms . /media/chris/FREECOM\ HDD/Backup/ --delete --exclude=".*/"
else
	echo "Backup Drive is NOT mounted"
	exit
fi
#EOF
I believe placement doesn't matter with rsync, so

Code: Select all

rsync -avzn --no-perms . /media/chris/FREECOM\ HDD/Backup/ --delete --exclude=".*/"
and

Code: Select all

rsync -avn --delete --exclude=".*/" /home/chris/ /media/chris/FREECOM\ HDD/Backup/
would functionally be the same thing.

Let me know.
User avatar
coffee412
Level 6
Level 6
Posts: 1083
Joined: Mon Nov 12, 2012 7:38 pm
Location: Indiana, USA
Contact:

Re: rsync syntax help for /home backup

Post by coffee412 »

Hi Chris,

I also backup using rsync. A little background on my setup: I backup my home directory on a 1tb drive to another 1tb drive in my system. It does this every morning at about 1:00AM. I have been doing this for about 6 months now.

My command line is simply:

rsync -a --exclude /home/coffee/dino /home/coffee /mnt/BACKUP

This will backup everything in my home directory except my simlink to my raid (dino) on another system that I store all my long term backups. This is basically all you ever need. What it does is copy over any files that have changed since the last backup.

I would also agree with Habitual that you should backup your .* files as these are your configuration files for your user login. Should you lose those then you will be in a world of hurt.

Have a great day,

coffee
Ryzen x1800 Asus Prime x370-Pro 32 gigs Ram RX480 graphics
IceWarp 12.0.3 * Mint 18.3 * RAID 1/5 * OpenVPN * Linux since kernel 2.0.36
************* Get Your Linux on! ***************
chiefjim
Level 5
Level 5
Posts: 963
Joined: Sun Jun 07, 2009 7:26 am
Location: South Texas, USA

Re: rsync syntax help for /home backup

Post by chiefjim »

I've been using the Grsync version for quite some time. So far I've not found a way to effectively have it skip cache files. Although not large in file size they take a proportionally large amount of time.
Mint-20.1 Mate 64 bit
Gigabyte H370M D3H
Intel G3258
Crucial Ballistic Sport 16GB DDR4 2400
8TB HDD Seagate Baracuda 5400rpm
chris_debian
Level 2
Level 2
Posts: 93
Joined: Fri Sep 24, 2010 5:14 am

Re: rsync syntax help for /home backup

Post by chris_debian »

Thanks, chaps.

Just giving rsync -a a go, and also grsync, to see what the difference is.

I prefer the simplicity of the terminal, and agree with you that the '.' files should be backed up. Also, I prefer to see what the rsync command is doing, so I assume the 'v' option is for verbose. I was surprised that the man page wasn't more explicit on this, but maybe I scrolled through too quickly.

Apologies for my delay in responding to your helpful answers.

Cheers,

Chris.
Reasons why you may want to try GNU/Linux:

http://www.whylinuxisbetter.net/
User avatar
austin.texas
Level 20
Level 20
Posts: 12046
Joined: Tue Nov 17, 2009 3:57 pm
Location: at /home

Re: rsync syntax help for /home backup

Post by austin.texas »

chiefjim wrote:I've been using the Grsync version for quite some time. So far I've not found a way to effectively have it skip cache files.
You can tell grsync to skip any folder. Create a file named grsync-exclude.txt and then tell grsync where the file is.

My grsync-exclude.txt file (all these will be excluded):
.adobe/
.cache/
.gnome2/
.macromedia/
.miro/
.mozilla/
.openshot/
.pulse/
.thumbnails/
.thunderbird/
.xine/
.kompozer.net/
Downloads/Miro/
hp-check.log
.gvfs/

Then after creating that file, open grsync and go to Advanced Options > Additional Options and add this line
to tell grsync the location of your grsync-exclude.txt file -
--exclude-from=/home/yourusername/grsync-exclude.txt
Mint 18.2 Cinnamon, Quad core AMD A8-3870 with Radeon HD Graphics 6550D, 8GB DDR3, Ralink RT2561/RT61 802.11g PCI
Linux Linx 2018
chiefjim
Level 5
Level 5
Posts: 963
Joined: Sun Jun 07, 2009 7:26 am
Location: South Texas, USA

Re: rsync syntax help for /home backup

Post by chiefjim »

austin.texas wrote:You can tell grsync to skip any folder. Create a file named grsync-exclude.txt and then tell grsync where the file is.
Thanks. Works great. Baffled at how a txt file works doing this.
Mint-20.1 Mate 64 bit
Gigabyte H370M D3H
Intel G3258
Crucial Ballistic Sport 16GB DDR4 2400
8TB HDD Seagate Baracuda 5400rpm
Habitual
Level 13
Level 13
Posts: 4861
Joined: Sun Nov 21, 2010 8:31 pm
Location: 0.0.0.0

Re: rsync syntax help for /home backup

Post by Habitual »

chris_debian wrote:Thanks, chaps.

Just giving rsync -a a go, and also grsync, to see what the difference is.

I prefer the simplicity of the terminal, and agree with you that the '.' files should be backed up. Also, I prefer to see what the rsync command is doing, so I assume the 'v' option is for verbose. I was surprised that the man page wasn't more explicit on this, but maybe I scrolled through too quickly.
Chris:
I not sure where you got this about man not being explicit but I read:

Code: Select all

man rsync
...
-v, --verbose               increase verbosity
and the other method is

Code: Select all

rsync --help | less
...
-v, --verbose               increase verbosity
What version are you using?

Code: Select all

rsync --version | head -1
mintybits
Level 6
Level 6
Posts: 1123
Joined: Fri Jan 27, 2012 5:09 pm

Re: rsync syntax help for /home backup

Post by mintybits »

Mine is like this:

Code: Select all

rsync -vaR --partial --filter='. filter' /home/me/ /backupfilepath/
And my "filter" file contains:

Code: Select all

- Backups
- .cache
- Cache
- cache
- temp
- .gvfs
- .thumbnails
- thumbnails
- Trash
Nick Payne
Level 3
Level 3
Posts: 101
Joined: Sun Feb 21, 2010 8:49 pm

Re: rsync syntax help for /home backup

Post by Nick Payne »

My exclude file contains the following:

Code: Select all

- .local/share/Trash/
- .local/share/wineprefixes
- .cache/
- .thunderbird/xtjje1ch.default/Cache/
- .thunderbird/xtjje1ch.default/startupCache/
- .gconf/
- .gvfs/
- .googleearth/
- .thumbnails/
- .mozilla/
- .kde/
- temp/
- .lilypond-fonts.cache-2/
- .adobe/
- .config/
- .wine/
- .wine-pipelight/
- .PlayOnLinux/
- PlayOnLinux's virtual drives/
- /*/.gvfs
And the rsync command line is

Code: Select all

rsync -rptgoDvSL --del --delete-excluded --exclude-from=/home/nick/scripts/exclude /home/nick/ /media/nick/BACKUP/nick/
User avatar
usbtux
Level 5
Level 5
Posts: 974
Joined: Tue Dec 28, 2010 10:37 am

Re: rsync syntax help for /home backup

Post by usbtux »

I use
rsync -r -n -t -p -v --progress -s --exclude VirtualBox* --exclude Dropbox --exclude Downloads --exclude /home/steve/.local/share/Trash /home/steve /media/steve/sharemedia/backup/020414

if you use time before the rsync it will it will tell you exactly how long it took to complete.
time rsync -r -n -t -p -v --progress -s --exclude VirtualBox* --exclude Dropbox...

http://www.electrictoolbox.com/rsync-ig ... ate-newer/
http://earthwithsun.com/questions/40887 ... ated-files
http://goo.gl/DXKgM LinuxMint tutorials.
Running LinuxMint 17.3 Mate. Pepermint 6 & Manjaro 15.12 Capella XFCE
http://goo.gl/WFu0u Installing Mint - the screen cast videos.
linuxcounter #368850
Post Reply

Return to “Other topics”