how to transfer a home-dir structure from one linux PC to another linux PC - linux

How can I transfer via tar the whole /home/.. tree with all the file attributes from one linux to another linux PC? I know I could write it to a tar file but I have not so much space on the target. Is there a way to pipe it with the tar command?

I would use rsync and ssh
Set up ssh
You need to install openssh-client on the receiving computer and openssh-server on the sending computer. Use the help distribution specific help docs for help setting this up.
rsync files
Go onto the 2nd computer and rsync the folder from the other first pc.
rsync -av ipofpc1:/home/ /home/

There are a variety of ways, but in this case I'd recommend using rsync.
First you need to install a SSH server on the target computer if you don't alrady have one running. For example on Debian/Ubuntu/Mint you'd do apt-get install openssh-server.
Then install rsync on the computer with the source folder. For example : apt-get install rsync.
And finally you can use rsync like this:
rsync --razh user#YOUR_OTHER_COMPUTER:/destination/path /home/

Related

Running a script during Debian Packaging

I have some source files and one bash script to run during installation in Ubuntu machines.
What is an easy guide to Debian packaging and create packages for own use?
My practice includes:
I made a sample which copies the files in to /usr/bin/ folder using pbuilder environment, but got struck with running a process.sh file which contains:
set -x
cpath=`pwd`
cd /usr/local/
mkdir libexec
cd
cd $cpath
cp askpin /usr/local/libexec/
cp badpin /usr/local/libexec/
cp msg /usr/local/libexec/
ldconfig
Any help is appreciated.
Traditionally these scripts go into the debian/DEBIAN directory along with the control file and are called preinst, postinst, prerm and postrm.
They are run when it is appropriate by the installation/removal process.
Include a shebang at the top of these files.
See: https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html
Edit:
Just chased down pbuilder and realised that the above answer probably means nothing to you.
I didn't know pbuilder existed, if I had maybe I would have used it, instead of scratching my debian builds into the bare metal, where the above answer makes sense.

Install chromium to Linux disk image?

I'm sure this has been asked before but I have no clue what to search for
I am trying to create a custom Linux image (for the Raspberry Pi) - I am currently manipulating the filesystem of the .img but I've discovered it's not as simple as dropping in the binary :( if only...
What is the accepted way to "pre-install" a package on a disk image where you can only manipulate the filesystem and ideally not run it first? Am I best to boot up, install, and then create the image from that, or is there a way of doing it beforehand in the same way you can change configuration settings etc?
Usually, when I have to change something in a disk image, I do the following:
sudo mount --bind /proc /mnt/disk_image/proc
sudo mount --bind /sys /mnt/disk_image/sys
sudo mount --bind /dev /mnt/disk_image/dev
These action are needed as this folder are create during boot process, mounting them in your system image will emulate a full boot. Then, you can chroot on it safely:
sudo chroot /mnt/disk_image
You're now able to issue commands in the chroot environment:
sudo apt-get install chromium
Of course, change /mnt/disk_image to the path where you have mounted your filesystem. apt-get will only works on Debian based system, change it according to your distribution.
You could find problem connecting to the internet and it can be cause by DNS configuration. The best thing you can do, is to copy your /etc/resolv.conf file in the remote filesystem as this file is usually changed by dhcp and it's empty on chroot environment.
This is the only solution that gives you full access to the command line of the system you're trying to modify.
This is an untested idea:
The dpkg tool, which can install .deb packages, has a --root option which can set a different filesystem than the local / path.
From the man page:
--instdir=dir
Change default installation directory which refers to the
directory where packages are to be installed. instdir is
also the directory passed to chroot(2) before running
package’s installation scripts, which means that the
scripts see instdir as a root directory. (Defaults to /)
--root=dir
Changing root changes instdir to dir and admindir to
dir/var/lib/dpkg.
If you mount your image and pass its mountpoint as --root, it should work.
There are things like the Ubuntu Customization Kit which allow you to create your own version of the distro with your own packages.
Crunchbang even has a utility like this, which is the distro I have personally selected for experimenting with my Pi.

linux (red hat) compare directories and copy over files that are different

I basically want rsync, but don't have the luxury of being able to install it.
But I need a way to deploy files from one server to another. I edit one or more files on one server and then need to copy all modified files to another server by comparing files that aren't the same (and being able to exclude .htaccess files)
Does anyone know of an easy way to do this?
Thanks,
Scott
(I will assume that you have shell access to both servers)
You do not need to install rsync system-wide. You can install it in your home-directory. First get a copy of the rsync binary for your distribution:
You can extract it from the rsync RPM package using rpm2cpio and cpio
You can copy it from another RedHat installation
You can copy it from another Linux installation for the same platform - there is a string possibility that it will work fine
Then you need to permanently modify the PATH environment variable so that the rsync command is found by your shell. If you do that for your user accounts in both servers, you can use rsync normally without the need for root privileges.
If you have access to install rsync on one server, that's all you need minimum.
If not, the question is what tools do you currently have available? scp? sftp? ftp? ssh? telnet? find?

Running apt-get for another partition/directory?

I have booted my system from a live Ubuntu CD, and I need to fix some package problems. I have mounted my hard drive, and now I want to run apt-get as if I booted normally. ie change the working directory for apt-get so it will work on my hard drive. I have done this before, but I can't remember the syntax. I think it was only some flag, like this:
apt-get --root-directory=/mnt/partition1 install....
But I only get "Command line option...is not understood". Any ideas?
Also this should work:
sudo apt-get -o Dir=/media/partitioni1 update
chroot /mnt/partition1
If your system uses several disk partitions you may have to mount some of them in order to get the package system working (I stopped setting up multiple partitions 10 years ago when hard disks started to get too large for raw physical backup).
This wouldn't work if you don't already have a usable debian system in that location. – akostadinov
If you can't get the package system working when chrooting, perhaps it is too messed up to ever be trusted again - in my experience the effort to bring it back to life rarely pays. If that happens, be happy you can still access your HD, backup your data and perform a clean reinstall.
Some relevant comments from other answer:
apt-get -o RootDir=/tmp/test_apt sets (almost) all paths to be in the different root. btw on a running system, if you copy /etc/apt, /usr/lib/apt, and mkdir -p usr/lib etc var/cache var/lib/dpkg var/lib/apt/lists/partial var/cache/apt/archives/partial and finally touch var/lib/dpkg/status, then apt is going to work in that root. It can even work as a non-root user if you add the option -o Debug::NoLocking=1. The nolock option is necessary because I couldn't find a way to set the lock file inside the different root directory. – akostadinov
Work means using search and downloading packages and such operations. Actually installing is not possible if some essential packages are not already there. debootstrap can help if the goal is actually installing packages in a new root for whatever reason. – akostadinov
Running chroot /mnt/partition1 will start a new shell in which the root of the filesystem is /mnt/partition1. Assuming the apt-get on your hard drive still works correctly, you can proceed from there.
dpkg --root=/mnt/partition1 -i mypackage.deb is an option that doesn't require chroot, but does require you to download the package yourself.

Creating a local Fedora repository with *Anonymous* rsync

I am trying to setup a local Fedora repository in a local LAN network.
Unfortunately I cannot run rsync in daemon mode because I'm behind a firewall on which I have no control.
Could anyone guide me on how to setup rsync using shell?
I tried the mirrors in http://mirrors.fedoraproject.org/publiclist , I get prompted for passwords. I thought these were supposed to be anonymous access. What am I doing wrong?
Lets say I want to create a local repository for Fedora 13 i386 os, what command would I need to issue on my local system?
Thanks in advance.
The mirrors on the website you linked should all be standard rsync:// mirrors without any passwords
Example:
mkdir os updates
rsync -av rsync://fedora.mirror.netriplex.com/Fedora/releases/13/Everything/i386/os/ os/
rsync -av rsync://fedora.mirror.netriplex.com/Fedora/updates/13/i386/ updates/
If you use cobbler, it will make sure the repositories are up to date for you so long as you cron a "cobbler sync".

Resources