LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Rsync failure? Strange deletion happened today. (https://www.linuxquestions.org/questions/linux-software-2/rsync-failure-strange-deletion-happened-today-4175658188/)

betajuice 07-28-2019 10:39 PM

Rsync failure? Strange deletion happened today.
 
I have a code project I was working on all day, and wanted to back up the project directory to an external hard drive. I reviewed the rsync manual page to make sure I had the options and source/destination correct. After executing rsync, my project directory was empty, and so was the intended destination. The command history below tells the full story, (ALMOST exactly as shown but I have only modified local username for privacy):

Details:
OS: Ubuntu 18.04.2 LTS
External HDD: WD Elements WDBPCK0010BBK 1TB usb 3.0
Starting directory: /home/bob/code/pgf

Code:

> ls -l /media/bob/Elements/code/Cpp/
> mkdir /media/bob/Elements/code/Cpp/pgf
> ls -l /media/bob/Elements/code/Cpp/
> man rsync
> cd ..
> rsync -rlptg pgf/ /media/bob/Elements/code/Cpp/pgf/
> ls -la /media/bob/Elements/code/Cpp/pgf/
> ls pgf
> ls
> ls -l pgf
> cd pgf
> ls
> man rsync
> ls
> ls
> ls -la

As you can see I was using ls frequently after the rsync command in disbelief that my files and sub-folders were gone.

Does anyone know what went wrong? My project is gone it seems and I have no idea how.

wpeckham 07-29-2019 08:04 AM

1. I note you did not run any command to show us your current directory during the command run.
2. Runnig an rsyn from a folder onto itself is not recommended, and I cannot confirm from the information provided that this did not occur.
3. The options
Quote:

rsync -av
would be a more secure and correct way to implement your options.
4. I note you did not include anything like to -del option or from that family of options, so nothing SHOULD have been deleted.
5. Copying to a new directory, why were you using rsync? IT is a wonderful tool for syncing, but there are faster ways to get that initial copy.
6. I would almost ALWAYS (a) include the -v option for verbose output, and (b) use full path names for safety and clarity when running rsync.

betajuice 07-29-2019 01:01 PM

Quote:

Originally Posted by wpeckham (Post 6019532)
1. I note you did not run any command to show us your current directory during the command run.
2. Runnig an rsyn from a folder onto itself is not recommended, and I cannot confirm from the information provided that this did not occur.
3. The options would be a more secure and correct way to implement your options.
4. I note you did not include anything like to -del option or from that family of options, so nothing SHOULD have been deleted.
5. Copying to a new directory, why were you using rsync? IT is a wonderful tool for syncing, but there are faster ways to get that initial copy.
6. I would almost ALWAYS (a) include the -v option for verbose output, and (b) use full path names for safety and clarity when running rsync.

1: At the time I was just running rsync, I wanted to paste the exact commands I ran in order, and in the beginning of my post I mentioned I was in the ~/code/pgf folder
2: Not sure what you mean? I ran rsync outside the source folder (see command #5, "cd .."), and to an external HDD directory.
3: ?
4: Right, which is why I'm confused.
5: Would cp have been a better command?
6: I will be sure to do this from now on (IF I ever use rsync again).

Thanks.

quickbreakfast 07-29-2019 08:25 PM

Quote:

Originally Posted by betajuice (Post 6019423)
Code:

> rsync -rlptg pgf/ /media/bob/Elements/code/Cpp/pgf/
> ls -la /media/bob/Elements/code/Cpp/pgf/
> ls pgf

Does anyone know what went wrong? My project is gone it seems and I have no idea how.

My guess is that you are missing the / at the beginning of the source of the command.

try
Code:


ls /pgf

and

Code:

rsync -rvlptg --update /home/bob/code/pgf/ /media/bob/Elements/code/Cpp/pgf
How big is the folder (100G or 1T?) and how long did it take?

The --update "switch" tells the computer to only deal with files that have appeared/ changed since last update, so will save heaps of time when next you do an upate of your back up.


All times are GMT -5. The time now is 06:49 PM.