Backup issue.

About writing shell scripts and making the most of your shell
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Locked
Moggertron

Backup issue.

Post by Moggertron »

Hi

I currently have Simple backup doing my backups for me. It backs up to a folder say sdb1/backups . I have made a basic alias that I can type at the command line which copies the sdb1/backups contents to an external hard drive /500gb/backups. The alias copies across all the new backups and updates existing copies if they have changed.

Simple backup is doing the logarithmic backup where it keeps 1 backup from today, 1 from yesterday, 1 from last week and so on. Simple backup does it's own deleting to keep things tidy which is my issue. While my alias copies all the new stuff across to the second backup area it doesn't delete the files that the originating backups folder no longer has. I'm not really sure how to get the second backup folder to dispose of these files. I'm going to change from the alias to a basic script that will run from cron.

I am wondering how to compare the source folder of backups to the secondary backups and keep them in line. I think I need to pipe a list from the source folder into grep -v or something and then remove the difference.

Any ideas ?
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Marios Zindilis

Re: Backup issue.

Post by Marios Zindilis »

I don't remember the specific option off the top of my head, but rsync can synchronize two folders and delete the excessive files in the destination folder (i.e. the ones that don't exist in the source folder any more).

Check out the man page and/or Google for "rsync examples", if you cannot find what you need I can doublecheck for you.
Moggertron

Re: Backup issue.

Post by Moggertron »

Thanks Marios. I will have a look and ask a bit more if I get stuck. Between google and man
pages I normally figure most things out.
mph426

Re: Backup issue.

Post by mph426 »

I think what you want is

Code: Select all

 rsync -av --delete
the -av is the most popular option, --delete keeps them identical.

If you want to do a dry run and see what it will do without making any changes use

Code: Select all

rsync -avn --delete
the -n is the dry run switch.

Code: Select all

man rsync
will give you much more info.
Locked

Return to “Scripts & Bash”