[Solved] rsync --link-dest (hard link backup files)?

If none of the more specific forums is the right place to ask

[Solved] rsync --link-dest (hard link backup files)?

Postby bester69 » 2018-06-20 22:11

Hi,

I found out some importat/big files deleted accidentally, and its not first time it happens to me,

I would like to do a mirror target backup , mirroring all files as hard links so I can prevent accidental file deletions (hardlinks backup) within some specific folders ..That way, when I find out some missing deleted files, I can go to "backup mirrored hardlinks folder" and restore the structure/files deleted.

How can I do it??, Can rsync do that?

Thanks.
Last edited by bester69 on 2018-06-21 10:48, edited 2 times in total.
bester69 wrote:There is nothing to install in linux, from time to time i go to google searching for something fresh to install in linux, but, there is nothing
User avatar
bester69
 
Posts: 1201
Joined: 2015-04-02 13:15

Re: rsync mirroring as hard links files?

Postby bester69 » 2018-06-20 23:41

Ive searched in internet and gave into
rsync --link-dest

I dont understand how this works, Im doing something like this.:
rsync -av --delete --link-dest=../linkedbackup/ source/ target/

I want a mirrored source backup in "--link-dest=../linkedbackup/" folder, where all files but directories should be hardlinks.. :? :?
bester69 wrote:There is nothing to install in linux, from time to time i go to google searching for something fresh to install in linux, but, there is nothing
User avatar
bester69
 
Posts: 1201
Joined: 2015-04-02 13:15

Re: rsync --link-dest (hard link backup files)?

Postby bester69 » 2018-06-21 03:16

I think I will use "cp -l" + find.:
Code: Select all
find -maxdepth 1 -type d  -iname "*" -exec cp -larv "{}" hardlinkbacks/ \;


I made a tested backup script with 3 date rotation retentions.:
hardback.sh
Code: Select all
################################
HLBACK=/media/sda1/.DDD
HLSOURCE=/media/sda1
HLNAME=`date +%Y%m%d_%H:%M:%S`
################################
touch $HLBACK/.1.dt $HLBACK/.2.dt
HL1=$(cat  $HLBACK/.1.dt)
HL2=$(cat  $HLBACK/.2.dt)

sleep 2
rm -rf $HLBACK/1-*
mv $HLBACK/2-$HL1 $HLBACK/1-$HL1
rm -rf $HLBACK/2-*
mv $HLBACK/3-$HL2 $HLBACK/2-$HL2
rm -rf $HLBACK/3-*
mkdir  $HLBACK/3-$HLNAME
###########
clear
echo "Directorios:"
find $HLSOURCE -maxdepth 1 -type d  -iname "*"  -not -path "$HLBACK" -not -path "$HLSOURCE"
echo "Archivos:"
find $HLSOURCE -maxdepth 1 -type f -iname "*"  -not -path "$HLBACK" -not -path "$HLSOURCE"
 #-not -path '*/\.*'
sleep 5
find $HLSOURCE -maxdepth 1 -type d  -iname "*"  -not -path "$HLBACK" -not -path "$HLSOURCE" -exec cp -larv "{}" $HLBACK/3-$HLNAME  \;
find $HLSOURCE -maxdepth 1 -type f -iname "*"  -not -path "$HLBACK" -not -path "$HLSOURCE" -exec cp -larv "{}" $HLBACK/3-$HLNAME  \;

###########
cat  $HLBACK/.2.dt >  $HLBACK/.1.dt
echo "$HLNAME" > $HLBACK/.2.dt
bester69 wrote:There is nothing to install in linux, from time to time i go to google searching for something fresh to install in linux, but, there is nothing
User avatar
bester69
 
Posts: 1201
Joined: 2015-04-02 13:15

Re: rsync mirroring as hard links files?

Postby bester69 » 2018-06-21 10:47

bester69 wrote:Ive searched in internet and gave into
rsync --link-dest

I dont understand how this works, Im doing something like this.:
rsync -av --delete --link-dest=../linkedbackup/ source/ target/

I want a mirrored source backup in "--link-dest=../linkedbackup/" folder, where all files but directories should be hardlinks.. :? :?

Ok, Here a good explanation
https://blog.interlinked.org/tutorials/rsync_time_machine.html

So in resume:
Step 0: rsync -aP $HOME/YourSource $HOME/Backups/current
>> Create a copy in folder "current"
Step 1: rsync -aP --link-dest=$HOME/Backups/current /$HOME/YourSource $HOME/Backups/back-2
>> Create a newCopy in folder "back-2" with hard linking destinity folder "current".
bester69 wrote:There is nothing to install in linux, from time to time i go to google searching for something fresh to install in linux, but, there is nothing
User avatar
bester69
 
Posts: 1201
Joined: 2015-04-02 13:15


Return to General Questions

Who is online

Users browsing this forum: No registered users and 5 guests

fashionable