I have a remote server that I can connect to via ssh, I need to restore files from there to my computer (preferably with folder structure or just filenames), ext4magic says that I cant restore it because of same partition or something (when I ssh into it), so I need to restore it to my pc. Now I used sshfs to mount remote /dev/vda1 to /mnt/vda1 on my pc, I did a command and it gave me an error. sudo ext4magic /mnt/vda1 -f / -a $(date -d -30days +%s) -r -d ../../home/felix/Documents/rc/ ./ Error 21 while opening filesystem ext4magic : EXIT_SUCCESS

I can't do it like that so I probably need to create an image from it, and restore from that img, can I do that? how can it be done? Is there a way to create iso file that I can try to restore files from? how can I do that? Thank you.


It's a bit unclear what you want to accomplish. Do you just want to copy files?

If you can connect to a remote server via ssh, you should also be able to do file transfers with scp to your local machine.

Let's say you want to copy everything in /var/www from the server to your local pc. I assume you use linux locally.

ssh user@remoteserver 
cd /var ; sudo tar czvf www.tgz www 
sudo mv www.tgz /home/user
chown user:user /home/user/www.tgz

Now from your local machine:

cd ~/directorywhereyouwantfile (if dir doesn't exist, create it.)
scp user@remoteserver:~/www.tgz .

if you want to extract it, do
tar xvzf ./www.tgz

Scp can also copy files recursively.

You can also backup the entire drive with this command:

cd / && sudo tar -cvpzf backup.tar.gz --exclude=/backup.tar.gz --one-file-system /

Then move backup.tar.gz to your home dir and chown to your own user, then scp as shown initially. Note you can check if you have sufficient disk space to make the archive with df -h. If you have a 300GB disk and 100GB free, there might not be sufficient space to make a full backup archive, whereas if you have used 100GB and you have 90GB free space, you probably have space for the backup archive.

You may also want to look into rsync, as rsync can work over ssh and is an excellent way to copy files from one linux machine to another.

  • I want to recover files that was removed. – Felix Oct 21 at 8:44
  • What I thought is maybe I can mount it through sshfs and create image from it, like iso, and then restore files from that image somewhere on my pc. Because I can't do that in ssh, there's only one dev and I can't restore files to the same disk. – Felix Oct 21 at 10:11
  • Here's some info about recovering files from ext4 systems (gillware.com/data-recovery-services/…), it doesn't seem trivial. If these files are very important, you might want to consider contacting professional data recovery experts. Wish you the best with this recovery task! – NordicViking Oct 21 at 15:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.