Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Accidentally did "mv /* ../" what should I do now?
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Accidentally did "mv /* ../" what should I do now?

FritzFritz Veteran
edited June 2017 in Help

Guys... I accidentally put that command as root on one of my boxes.

What should must I do now? Any suggestion? :(

Can I restore the files? The server is now dead I believe.

Any thoughts/ idea is greatly appreciated.

Thanks

«1

Comments

  • RhysRhys Member, Host Rep
    edited June 2017

    Reinstall and restore from backups and if you don't have backups, sucks to be you.

  • m3gfm3gf Member
    edited June 2017

    mv ../* /root/

  • XeiXei Member

    Is this really fixable? I'd guess not and restore from backup is required.

  • FritzFritz Veteran

    @m3gf said:
    mv ../* /root/

    SSH service is down, all commands are not recognized either.

    I'll try to contact my provider first.

    Is there anything else I can do? :(

  • Which folder did you run this command in?

  • yokowasisyokowasis Member
    edited June 2017

    Is that command even possible. Doesn't "/" refer to the root vps directory. I don't think there is anything beyond root directory.

  • RhysRhys Member, Host Rep

    @yokowasis said:
    Is that command even possible. Doesn't "/" refer to the root vps directory. I don't think there is anything beyond root directory.

    translates to move everything in / to one directory back from $PWD, which will work.

  • pikepike Veteran

    https://unix.stackexchange.com/questions/17428/moved-bin-and-other-folders-how-to-get-them-back

    If your ssh doesnt work and have no backups you've fucked up.
    Next time create some backups and be fine, it's easy to automate this.

  • FritzFritz Veteran

    @Rhys said:

    @yokowasis said:
    Is that command even possible. Doesn't "/" refer to the root vps directory. I don't think there is anything beyond root directory.

    translates to move everything in / to one directory back from $PWD, which will work.

    Does it mean the files can be restored?

  • XeiXei Member

    What folder did you enter the command in?

  • If it is a VPS and if it does not have encrypted FS provider can help, if he wishes to.
    Disk image can be mounted and accesed from outside, and if it is simfs/openvz it is even simplier.

  • AnthonySmithAnthonySmith Member, Patron Provider
    edited June 2017

    Boot the vps in to sysrescue run testdisk or gparted find the data, backup what you need, restore.

    If it is OpenVZ.. ask your host for help

    If you really need the data and have no idea how to recover it and would rather wait until Wednesday than lose it give me a shout I will try and recover it for you.

  • As @AnthonySmith clarified, if this is OpenVZ, best to ask the host for help. The files aren't lost - they're just in the wrong place and so your VPS can't be used "directly". Most probably "vzctl enter" will also fail as it will not be able to find bash/sh in the VM in the correct location but that can easily be fixed by the host.

    You should probably also tell your host WHERE you ran the command (assuming you remember, because relative to that folder is where the mv has moved the files).

    For KVM it's easier and self-doable. Use any rescue disk (or live cd) and just mount your disk/root fs and rerun the mv to move things back to the correct location and you should be all set. Again, you'll need to know/find out where you ran the command to know the new location of all the files.

    The original command probably failed at some point because of either the pseudo fs's or some other related errors - so you may well find that only some of the original / paths were moved.

    Hope this helps and good luck.

  • trewqtrewq Administrator, Patron Provider

    If you really need the data you might be able to slide the host a tenner for the VPS image file.

  • @trewq said:
    If you really need the data you might be able to slide the host a tenner for the VPS image file.

    Tenner? I was going to offer them a fiver and A FAKING SHOEY MATE

    Thanked by 1Nekki
  • GamerTech24GamerTech24 Member
    edited June 2017

    if your VPS provider has a recovery mode try that as a last resort, see if anything is still on the disk

  • @Fritz said:

    @Rhys said:

    @yokowasis said:
    Is that command even possible. Doesn't "/" refer to the root vps directory. I don't think there is anything beyond root directory.

    translates to move everything in / to one directory back from $PWD, which will work.

    Does it mean the files can be restored?

    If it's KVM, mount a recovery ISO and move everything back.

  • raindog308raindog308 Administrator, Veteran

    wwabbit said: Which folder did you run this command in?

    Xei said: What folder did you enter the command in?

    He used an absolute path for the source, but a relative path for the destination:

    mv /* ../

    So "move all root entries to the directory about me".

    If you did...

    # mkdir -p /tmp/one/two
    # cd /tmp/one/two
    # mv /* ../
    

    ...then this might recoverable but I'm guessing the parent directory is either above his root fs (does OvZ really allow this!?!? Isn't that a massive security hole?) or somewhere else inconvenient.

    Also, @jarland I am amazed that this conversation with all of its slashes and paths is not CloudFlare'd.

  • FritzFritz Veteran
    edited June 2017

    @AnthonySmith

    I'll try to solve this together with my hoster first, I'll definitely contact you if he can't solve this.

    @raindog308

    Unfortunately, the SSH is also down (together with the "bin" folder) and atm no serial console can be used. I guess the only way is I have to ask for a help to my host and yes it is OpenVZ.

    Thanks guys for all your help. :)

  • angstromangstrom Moderator

    @Fritz said: Any thoughts/ idea is greatly appreciated.

    Use fewer slashes/ slashes.

    On a more serious note, using a file manager (e.g., mc) can help to prevent such mistakes.

  • AnthonySmithAnthonySmith Member, Patron Provider

    Fritz said: I have to ask for a help to my host and yes it is OpenVZ.

    yep, I can't help remotely if it is openvz sorry, but the good news is it should be incredibly simple for your host to recover.

  • brueggusbrueggus Member, IPv6 Advocate

    AnthonySmith said: but the good news is it should be incredibly simple for your host to recover.

    ...at least if his knowledge goes beyond installing WHMCS and SolusVM on a rented dedi.

  • AnthonySmithAnthonySmith Member, Patron Provider

    brueggus said: ...at least if his knowledge goes beyond installing WHMCS and SolusVM on a rented dedi.

    It's not quite summer yet so hopefully it will be fine :)

    Thanked by 1Fries
  • FritzFritz Veteran

    Hopefully he is able to do that. He is a well known LET hoster here.

  • FritzFritz Veteran
    edited June 2017

    Hi,

    @AnthonySmith
    @raindog308

    My host has put back all the files into a folder in /home/user/*

    There are all files and folders, including bin, etc, opt, home folder etc.

    They also put similar folder in "/" (root) directory so that my box is able to run again.

    The question is, can I just move all the files in /home/user/* and overwrite all folders in the root folder ("/")?

    Many thanks

  • @Fritz said: The question is, can I just move all the files in /home/user/* and overwrite all folders in the root folder ("/")?

    I suggest you check using rsync with the "-n" option to see if anything is missing and only sync those as opposed to a blind mv.

    Here's a rough rsync command (see man for more details/other options for your needs):

    rsync -niavPHXASc /home/user/ / --exclude /home/user/ --exclude /dev --exclude /proc --exclude /sys

    the --delete option may also be handy.

    The c option may be a bit heavy CPU wise and you may also benefit by using options like --no-time and/or --numeric-ids

    Also beware about files in /etc (like interfaces).

    Playing around a bit with the rsync options will give you a very good idea if anything has changed and then you can decide what you want to do about it.

    Hope this helps.

  • brueggusbrueggus Member, IPv6 Advocate
    edited June 2017

    My recommendation would be:

    • Backup all files you still need
    • Reinstall
    Thanked by 1Pwner
  • @nullnothere said:

    @Fritz said: The question is, can I just move all the files in /home/user/* and overwrite all folders in the root folder

    ("/")?

    I suggest you check using rsync with the "-n" option to see if anything is missing and only sync those as opposed to a blind mv.

    Here's a rough rsync command (see man for more details/other options for your needs):

    rsync -niavPHXASc /home/user/ / --exclude /home/user/ --exclude /dev --exclude /proc --exclude /sys

    the --delete option may also be handy.

    The c option may be a bit heavy CPU wise and you may also benefit by using options like --no-time and/or --numeric-ids

    Also beware about files in /etc (like interfaces).

    Playing around a bit with the rsync options will give you a very good idea if anything has changed and then you can decide what you want to do about it.

    Hope this helps.

    Take a backup before rsync because if any thing happen wrong all the things will mess up

  • FritzFritz Veteran

    @nullnothere said:

    @Fritz said: The question is, can I just move all the files in /home/user/* and overwrite all folders in the root folder ("/")?

    I suggest you check using rsync with the "-n" option to see if anything is missing and only sync those as opposed to a blind mv.

    Here's a rough rsync command (see man for more details/other options for your needs):

    rsync -niavPHXASc /home/user/ / --exclude /home/user/ --exclude /dev --exclude /proc --exclude /sys

    the --delete option may also be handy.

    The c option may be a bit heavy CPU wise and you may also benefit by using options like --no-time and/or --numeric-ids

    Also beware about files in /etc (like interfaces).

    Playing around a bit with the rsync options will give you a very good idea if anything has changed and then you can decide what you want to do about it.

    Hope this helps.

    Hi,

    Will that rSync the file permission too?
    I got weird result,

    rsync: connection unexpectedly closed (201608 bytes received so far) [sender] rsync error: error in rsync protocol data stream (code 12) at io.c(600) [sender=3.0.6]

  • FritzFritz Veteran
    edited June 2017

    Some updates:

    1. The server has been reinstalled and configured using old data (rsync does not work in this case)
    2. Everything went very smooth and successfully
    3. My Host helped me a lot, thanks to @cociu
    Thanked by 2cociu Junkless
Sign In or Register to comment.