Return to Level1Techs.com

Linux equivalent of ROBOCOPY?

Hey guys! I recently moved my media server and backups to Linux Mint 19 from Windows 10 and I’m looking for a direct replacement/solution to ROBOCOPY /MIR. I’ve seen multiple posts about using RSYNC and nested CP commands, but ROBOCOPY /MIR D:\Media E:\Backup mirrors everything from D:\Media to E:\Backup, including new files, changed files, added folders and even removes files/folders no longer on the source from the destination drive.

I can’t believe I’m saying this, but is it possible that Windows has a command line utility that is better than any Linux offering?

1 Like

The Linux equivalent would be dd. Can check out more about it’s usage here

rsync will do that with the right options. -a will do most things you want and --delete will delete files from the destination that are no longer in the source

11 Likes

I’m going to go with RSYNC. I’ve been using it since I left Windows years ago and used it at work afterwards. For example:

I have a collection of Comic books seperated by Publisher as follows:

/home/Downloads/Marvel, 
/home/Downloads/DC, 
/home/Downloads/Image
/home/Downloads/Fixed

I want to rsync those to a backup drive"
/run/media/$USER/WD-My-Book

I can write a simple for loop and put it in a bash script to do this with RSYNC !
for $i in '/home/Downloads/Marvel' '/home/Downloads/DC' '/home/Downloads/Image' '/home/Downloads/Fixed'; do rsync -ahv $i '/run/media/$USER/WD-My-Book/'; done

I can even put this in a cron job and run it on schedule.

Files from mirrored directories can be done with flags like:
rsync --rtuv --delete D:\ /whatever/directory/you/want

System updates can be done with rsync as well excluding certain files if needed preserving permissions and shortcuts etc:
rsync -aAXv / --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found","/home/*"} /another/location/if_needed/

Simple backups with rsync are usually done with:

rsync -ahv D:\ /to/my/directory

If you have any questions just reply here, rsync is amazing and can litereally do it all !

4 Likes

99% sure you could do that with rsync and the right options

6 Likes

Agreed, I’ve always been able to achieve whatever I do with robocopy with rsync.

@tabun The /MIR option in robocopy isn’t magic, it’s the same as using other options.

This is my rsync script to sync a directory to my USB stick:

#!/bin/sh
rsync -av --delete ~/Documents/Work_Docs/ /run/media/BGL/16GIB/Work_Docs/

EDIT: just read @Magnus_Python post in full. Great examples :slight_smile:

3 Likes

Thanks everyone. I’ll try RSYNC. When I first looked into it, I was reading a lot about RSYNC servers, etc. and it seemed to be way more than what I was looking for.

3 Likes

Yeah, you can ssh and backup over a network if you need to as well. If you come across something you need just reply.

1 Like

RClone is good as well

1 Like

Hi everyone I have a quick question, What software do you use to backup your Linux programs and settings? I was using Timeshift to take what I thought were snapshots of my SSD, but when I had to restore an earlier snapshot after timeshift was done restoring my system, I found all the Linux programs I had installed where gone, also the settings I made after I installed Linux Mint 19.03 but before my first Timeshift snapshot was gone. I thought I set up Timeshift to make a snapshot of all settings and installed programs.

Also, I have another question that is kind of related to the topic of these posts. How would you add a large hard drive to Linux Mint? I have an 8TB hard drive I purchase along with the parts for my new build. I haven’t installed the drive yet to my new build. I plan on doing that tomorrow and was wondering what is the best way to add a large hard drive to Linux Mint. My plan for the large hard drive is added my large video collection to it. Also, I plan to use the hard drive as a backup for my Home directory and all my settings for Linux Mint. I plan when money isn’t so tight to purchase a 10TB or a 12TB external hard drive to use for my backups. I currently don’t have any backups and I know this isn’t smart.

Also, I would like your opinion about this Youtube video I found that seems to show how to set up an additional hard drive to whatever distro of Linux you are using.

I also would be very interested in what @Magnus_Python, @BGL, @Vader, @Dexter_Kane, @2bitmarksman that about what I have asked.

I didn’t watch the video in full but it looks like it’s showing you the right stuff.

On my Linux machine (which is also Mint) I have a 2TB HDD which holds my steam folder and assorted virtual disk files for VM’s. I simply have a /storage folder in root and then mount the 2TB drive to that in /etc/fstab (as shown in the video).

As for backups I rely on my OneDrive and PCloud. I do have Timeshift configured for local backup of my home home directory but TBH if my system gets messed up I usually nuke and pave :slight_smile:

1 Like

I personally use rsync scripts I have written over the years. My current setup is a reflection of my time learning Linux piecemealing things together. If I were to somehow start fresh now, I would do things very differently.

When I started I have little to no knowledge of LVM, and File system snapshots outside of the stuff I learned from Windows Backup tools.

For those who need simple Directory backups or File system backups I would go with a tool like Timeshift or rsync.

Here is a video tutorial on Timeshift from Chris Titus TV. I have never used the tool, but have heard good things about it. Very new user friendly.

Well, the video you posted would cover mounting a drive to the system quiet well, and should be able to use Timeshift to put your backups there as well.

2 Likes

I have a Blog post on the forum coming about this. . . It’s time for a change.

3 Likes

Good. I’m at that beginning stage now and with so many ways to accomplish the same thing in Linux, I sometimes hold my breath when trying something unknown to me and it works…although I’m wondering the entire time if it was the best or most efficient way and if I took unnecessary steps.

I tried the instructions for adding a new unformatted hard drive in a virtual machine. I can’t get it to work or it’s not working right. I have destroyed 7 virtual machines today trying to get this to work. By following the instructions in the video, I can create the two Primary partitions I want to create. The first problem I came across is in the version of Linux Mint I am running they removed the command gksudo to start Nemo in root privileges, supposedly you can type the following command sudo Nemo and that will give you root privileges to Cinnamon file manager. I am going to try one more time with the same version of Linux Mint Joe Collons uses and see if that works.

Thanks, everyone for your help. I am determined to kick Linux ass. If I wasn’t I would have given up on Linux and reformated my SSD’s for Windows, especially after a day like today. Thanks for letting me blow off some steam.

Hey, Magnus Python I just want to encourage you to go and blog about everything Linux. You have two newbies to Linux that are willing to absorb all your Linux knowledge you are willing to share.

1 Like

Uhh… this might not be the answer you’re looking for but usually tar
https://help.ubuntu.com/community/BackupYourSystem/TAR
I have a separate / and /home, from time to time I’d run a short script I wrote to backup /.
On /home I usually backup just my config dirs and dot files, pretty much everything else is synced across my machines over Syncthing, I recommend checking it out.

If I’m feeling lazy I’d just dd the entire SSD and pipe it through xz to compress it. Useful for complete system backups or migrating to another drive, even if a bit time consuming.

1 Like

I’m pretty sure the for-loop isn’t necessary. You can pass multiple source directories.

Man page synopsis (e.g. local move) -

Local:  rsync [OPTION...] SRC... [DEST]

So, single destination, but multiple sources possible.

1 Like

Couple different ways. One way -

For my VMs, which I host in ZFS, I’ll usually shut them completely down and snapshot, followed by replication of that snapshot(s) to another storage pool. If you’re working with a physical machine, I’d recommend the above (works quite well) or booting the hardware on a USB drive, followed by either dd’ing or rsyncing the contents of that root block device to another storage media.

1 Like

there are a few ways to do this.
first gparted to partition and format the drive.
If it is just for backup and storage of files you can format it with the fat 32 which almost any version of linux can read
you can use dd via command line or just use clonezilla (partition to partition) (clonezilla offers many forms of cloning including network cloning)
or you can use rsync

Once you do find the appropriate options, you can create an alias in your .bashrc.

also note that rsync has some odd behavior regarding the meaning of the trailing slash for the destination argument.

It’s also quite probable that windows has a handful of utilities that can beat the usability or the gnu Posix utilities, which have a long history and a lot of cruft.

The reason rsync is so favored, is that it’s pretty much guaranteed to be found on any system. There are certainly more approachable tools out there, some with CLI’s , but rsync remains the lowest common denominator and works reasonably well with runtime options to fit almost any situation.