LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-03-2019, 09:56 AM   #1
l043nz0
LQ Newbie
 
Registered: Mar 2019
Posts: 16

Rep: Reputation: Disabled
Unhappy rsync problem


Hi to all,
this is my first post, thanks to all.

I have a vps.
I added an external disk, the fstabs

/dev/sda1 / ext4 errors=remount-ro,discard 0 1
/dev/sdb1 /mnt/mydisk ext4 nofail 0 0
/dev/sdb1 /var ext4 defaults 0 2

i want to move the /var dir to sda1.

i commented #/dev/sdb1 /var ext4 defaults 0 2

rebooted vps and launched rsync -aqxP /mnt/mydisk /var/*

my sda1 space growth, but i don't see the files..

what's wrong?

I think that i have a prolem in rsync command..
Hope someone can help me.

Thanks
 
Old 03-03-2019, 10:07 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,892

Rep: Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317
no, it is definitely more complex. You cannot move the /var of a living system.
when you reboot your system /var will be created again, most probably that will be an empty directory. But during boot some files/dirs will be also automatically created. I have never tried it, but I think /var/* is not a single directory.

I would rather boot a live cd, do the copy and reboot the original system only when /var was already copied.
 
Old 03-03-2019, 10:17 AM   #3
l043nz0
LQ Newbie
 
Registered: Mar 2019
Posts: 16

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
no, it is definitely more complex. You cannot move the /var of a living system.
when you reboot your system /var will be created again, most probably that will be an empty directory. But during boot some files/dirs will be also automatically created. I have never tried it, but I think /var/* is not a single directory.

I would rather boot a live cd, do the copy and reboot the original system only when /var was already copied.
Many thanks for reply.

I'm sorry, but i used this guide https://linuxconfig.org/how-to-move-...ther-partition

Now, i want to move to original position /var dir.

I talk about a virtual private server, i can't use a live cd.
thanks
 
Old 03-03-2019, 10:19 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,892

Rep: Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317
based on that page you simply mistyped the command. But I'm still not sure if that works perfectly.
 
Old 03-03-2019, 10:22 AM   #5
l043nz0
LQ Newbie
 
Registered: Mar 2019
Posts: 16

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
based on that page you simply mistyped the command. But I'm still not sure if that works perfectly.
Thanks.

I used that guide more months ago.
It works perfectly.

Now, i want to move /var to original position.
 
Old 03-04-2019, 12:42 AM   #6
Beryllos
Member
 
Registered: Apr 2013
Location: Massachusetts
Distribution: Debian
Posts: 529

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
That guide tells how to move /var to an external hard drive. Is that what you did months ago? If you followed that procedure, it would work.

What is it you are trying to do now? Do you want to move /var from the external drive back to the internal hard drive?

Last edited by Beryllos; 03-04-2019 at 12:47 AM.
 
Old 03-04-2019, 01:12 AM   #7
l043nz0
LQ Newbie
 
Registered: Mar 2019
Posts: 16

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Beryllos View Post
That guide tells how to move /var to an external hard drive. Is that what you did months ago? If you followed that procedure, it would work.

What is it you are trying to do now? Do you want to move /var from the external drive back to the internal hard drive?
Yes, correct!
 
Old 03-04-2019, 10:53 AM   #8
Beryllos
Member
 
Registered: Apr 2013
Location: Massachusetts
Distribution: Debian
Posts: 529

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
Okay. I will get back to your plan to move /var, but first I want to explain why rsync did not work as you expected. It is because you specified the destination with a wildcard.

On my system, rsync does not accept that command. No files are transferred, and I get an error message. You mentioned that the sda1 space changed, so something got tranferred. My rsync is probably a different version than yours.
Edited to add: Sorry, rsync on my system does accept that command. It failed for another reason, file permissions.

On your system. what probably happened is that the command interpreter expanded the wildcard and then rsync used the expansion. rsync would then copy the source directory which you intended to transfer, and all but the last item in the wildcard expansion, and add them all to the last item in the wildcard expansion. In other words, one of the subdirectories of /var now contains (1) some files that belong there, (2) the files you intended to transfer to /var, and (3) a lot of other files that don't belong there.

Last edited by Beryllos; 03-04-2019 at 02:54 PM.
 
Old 03-04-2019, 11:02 AM   #9
l043nz0
LQ Newbie
 
Registered: Mar 2019
Posts: 16

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Beryllos View Post
Okay. I will get back to your plan to move /var, but first I want to explain why rsync did not work as you expected. It is because you specified the destination with a wildcard.

On my system, rsync does not accept that command. No files are transferred, and I get an error message. You mentioned that the sda1 space changed, so something got tranferred. My rsync is probably a different version than yours.

On your system. what probably happened is that the command interpreter expanded the wildcard and then rsync used the expansion. rsync would then copy the source directory which you intended to transfer, and all but the last item in the wildcard expansion, and add them all to the last item in the wildcard expansion. In other words, one of the subdirectories of /var now contains (1) some files that belong there, (2) the files you intended to transfer to /var, and (3) a lot of other files that don't belong there.
Perfect Beryllos.
I think you are centered the point.
If you see this thread https://www.linuxquestions.org/quest...4/#post5969709
(is a test), all data moved on last directory of destination.

Tonight (i'm in cet time), i'm going to unmount disk2 and try to find where data was copied.. .
thanks
 
Old 03-04-2019, 01:50 PM   #10
Beryllos
Member
 
Registered: Apr 2013
Location: Massachusetts
Distribution: Debian
Posts: 529

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
pan64 is right. You should not move /var on a live system. You might be able to do it, but there are problems. The procedure in the article works because (1) you can copy /var to another drive, and (2) /var is reassigned to the external hard drive through fstab when you reboot.

The reverse process is harder. The difficulty is that you need to copy var back to sda1 before rebooting, and you need to copy it into the directory /var which is already being used as the mount point for the external hard drive. I don't know how to copy files to a mount point and not the mounted drive. Maybe there is a trick for this.

What you attempted to do is to copy the files after reboot. The problem, as pan64 wrote, is that upon reboot, the system immediately starts using the directory /var which was previously only a mount point. When you copy the files from the external drive to /var, you are attempting to overwrite files which the system is using.

Below I will give you the correctly-formed rsync command, but I cannot be sure it will work. The system may prevent some files from being copied, and if so, rsync will give error messages to let you know. If the system allows active files to be overwritten, the content of those files may become inconsistent, but perhaps the system will carry on satisfactorily after that.
Code:
rsync -aqxP /mnt/mydisk/* /var
As pan64 wrote, it would be safer to do this from a live cd, so that no active files are overwritten.
 
1 members found this post helpful.
Old 03-04-2019, 02:43 PM   #11
l043nz0
LQ Newbie
 
Registered: Mar 2019
Posts: 16

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Beryllos View Post
pan64 is right. You should not move /var on a live system. You might be able to do it, but there are problems. The procedure in the article works because (1) you can copy /var to another drive, and (2) /var is reassigned to the external hard drive through fstab when you reboot.

The reverse process is harder. The difficulty is that you need to copy var back to sda1 before rebooting, and you need to copy it into the directory /var which is already being used as the mount point for the external hard drive. I don't know how to copy files to a mount point and not the mounted drive. Maybe there is a trick for this.

What you attempted to do is to copy the files after reboot. The problem, as pan64 wrote, is that upon reboot, the system immediately starts using the directory /var which was previously only a mount point. When you copy the files from the external drive to /var, you are attempting to overwrite files which the system is using.

Below I will give you the correctly-formed rsync command, but I cannot be sure it will work. The system may prevent some files from being copied, and if so, rsync will give error messages to let you know. If the system allows active files to be overwritten, the content of those files may become inconsistent, but perhaps the system will carry on satisfactorily after that.
Code:
rsync -aqxP /mnt/mydisk/* /var
As pan64 wrote, it would be safer to do this from a live cd, so that no active files are overwritten.
okok, many thanks Beryllos!
 
Old 03-04-2019, 03:39 PM   #12
l043nz0
LQ Newbie
 
Registered: Mar 2019
Posts: 16

Original Poster
Rep: Reputation: Disabled
OK, i found the duplicate data:

/var in the external disk is:
Code:
root@machine:/var# ls
backup  backups  cache  lib  local  lock  log  lost+found  mail  opt  puppet  run  spool  tmp  www
root@machine:/var# cd www
root@machine:/var/www# ls
backup   cache  html  local  log         mail  prestashop  run    tmp
backups  disk   lib   lock   lost+found  opt   puppet      spool
/var in the primary disk (after wrong command rsync -aqxP /mnt/mydisk /var/* )
Quote:
root@machine:/var# ls
backup backups cache lib local lock log lost+found mail opt puppet run spool tmp www
root@machine:/var# cd www
root@machine:/var/www# ls
backup cache html local log mail prestashop run tmp
backups disk lib lock lost+found opt puppet spool www
root@machine:/var/www# cd www
root@machine:/var/www/www# ls
backup cache html local log mail prestashop run tmp
backups disk lib lock lost+found opt puppet spool
root@machine:/var/www/www#

i think i can delete /var/www/www
correct?
 
Old 03-04-2019, 05:37 PM   #13
Beryllos
Member
 
Registered: Apr 2013
Location: Massachusetts
Distribution: Debian
Posts: 529

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
It looks like /var/www/www can be deleted, but it may be useful to keep it until you figure out what happened. I am not sure why /var/www/www is there. Did you run the incorrect rsync command two times, or more? Duplicate files and directories may exist in /var, /var/www, and /var/www/www. I am not sure of the best way for you to determine which are duplicates and may be deleted. (I would use md5deep but it is not very user-friendly.)
 
Old 03-05-2019, 12:42 AM   #14
l043nz0
LQ Newbie
 
Registered: Mar 2019
Posts: 16

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Beryllos View Post
It looks like /var/www/www can be deleted, but it may be useful to keep it until you figure out what happened. I am not sure why /var/www/www is there. Did you run the incorrect rsync command two times, or more? Duplicate files and directories may exist in /var, /var/www, and /var/www/www. I am not sure of the best way for you to determine which are duplicates and may be deleted. (I would use md5deep but it is not very user-friendly.)
Yes, i run ithe wrong command many Times..
I think that the best way is to reinstall the os.. first i can backup data (prestashop directory and database), reinstall os and restore prestashop files and db..
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
rsync solaris + ld.so.1: rsync: fatal: libiconv.so.2: open failed: xxx_anuj_xxx Solaris / OpenSolaris 25 02-23-2012 03:23 AM
rsync can not rsync files with include filter... xiutuo Linux - Server 2 07-23-2010 02:10 AM
Could I run rsync to download files from a server without rsync daemon? Richard.Yang Linux - Software 1 09-18-2009 04:08 AM
Rsync server vs rsync over ssh humbletech99 Linux - Networking 1 10-18-2006 12:10 PM
Windows Rsync Upload to Linux Rsync - permissions inspleak Linux - Software 0 10-12-2004 02:49 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:30 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration