LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 04-06-2016, 02:00 PM   #16
biosboy4
Member
 
Registered: Aug 2015
Distribution: Debian, SUSE, NXOS
Posts: 242

Original Poster
Rep: Reputation: 38

I'm not following you. How do I point rsync to the vm images?
 
Old 04-06-2016, 02:02 PM   #17
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,295
Blog Entries: 3

Rep: Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719
If you can ssh to the machine, then you can use rsync since rsync goes over ssh automatically. But you have to know where your files are. If you are not sure, see the find example above.
 
Old 04-06-2016, 02:21 PM   #18
biosboy4
Member
 
Registered: Aug 2015
Distribution: Debian, SUSE, NXOS
Posts: 242

Original Poster
Rep: Reputation: 38
Can you help me with the ssh/rsync command?

The files are at var/vmfs/volumes
 
Old 04-06-2016, 02:29 PM   #19
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,295
Blog Entries: 3

Rep: Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719
Quote:
Originally Posted by biosboy4 View Post
Can you help me with the ssh/rsync command?

The files are at var/vmfs/volumes
It would be something like this:

rsync -av server.example.com:/var/vmfs/volumes/ /mnt/path/to/backup/volumes/

where you substitute your own source machine name and your own destination path. It goes automatically over SSH but will ask for a password. Once that is working you can set up keys and an agent and avoid the password authentication.
 
Old 04-06-2016, 03:21 PM   #20
biosboy4
Member
 
Registered: Aug 2015
Distribution: Debian, SUSE, NXOS
Posts: 242

Original Poster
Rep: Reputation: 38
Looks like rsync has to be installed on the ESXi host as well. So I either need to figure out how to install it or maybe I can just go with copy commands and do full backups everytime instead of incremental. I have 8-16TB of space available on the backup server anyways.
 
Old 04-06-2016, 03:34 PM   #21
biosboy4
Member
 
Registered: Aug 2015
Distribution: Debian, SUSE, NXOS
Posts: 242

Original Poster
Rep: Reputation: 38
Ok, what would a standard copy command look like through the ssh to ESXi02? I'm going to just try to grab the files quick and dirty like that.

Edit: I just found this:


http://blog.magiksys.net/run-rsync-i...on-vmware-esxi

http://www.virtuallyghetto.com/2011/...ked-rsync.html

https://damiendebin.net/blog/2013/12...t-1-and-rsync/



I'm going to do it. Wish me luck.

Last edited by biosboy4; 04-06-2016 at 05:22 PM.
 
Old 04-07-2016, 02:19 PM   #22
biosboy4
Member
 
Registered: Aug 2015
Distribution: Debian, SUSE, NXOS
Posts: 242

Original Poster
Rep: Reputation: 38
Ok when I try this:

[root@esxi02-b:~] cp -r /vmfs/volumes/54ef4c22-27a271ae-b5c4-000af77e3720/ASTRABESSVEEAM /AKRYPT-LINUX/bakhak

I get the following:

cp: write error: no space left on device

What am I doing wrong? I shared the location with Samba and gave write permissions to everyone.
 
Old 04-08-2016, 01:34 AM   #23
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,295
Blog Entries: 3

Rep: Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719
Quote:
Originally Posted by biosboy4 View Post
Ok when I try this:

[root@esxi02-b:~] cp -r /vmfs/volumes/54ef4c22-27a271ae-b5c4-000af77e3720/ASTRABESSVEEAM /AKRYPT-LINUX/bakhak

I get the following:

cp: write error: no space left on device

What am I doing wrong? I shared the location with Samba and gave write permissions to everyone.
/AKRYPT-LINUX/bakhak is on the same machine as /vmfs/volumes/54ef4c22-27a271ae-b5c4-000af77e3720/ASTRABESSVEEAM, maybe even the same partion, and there is no space in the partition where [b]/AKRYPT-LINUX/bakhak[b] resides.

What you want is to be on the destination machine and copy using rsync. rsync is better for large files, especially if there is an interruption or repeated copy. So it should be something like this:

rsync -av esxi02-b:/vmfs/volumes/54ef4c22-27a271ae-b5c4-000af77e3720/ASTRABESSVEEAM /AKRYPT-LINUX/bakhak/

If ASTRABESSVEEAM is a file, then the above is ok. Otherwise, if it is a directory, then you need to have a slash after it too. (The -a equals -rlptgoD and they are all in the man page for rsync.)

Can ASTRABESSVEEAM be copied without being root? Logging in as root is more than a small faux pas these days, so figuring out a way around that will have to be on your list of things to do.
 
Old 04-08-2016, 09:26 AM   #24
biosboy4
Member
 
Registered: Aug 2015
Distribution: Debian, SUSE, NXOS
Posts: 242

Original Poster
Rep: Reputation: 38
Thanks!

Here's where I am now:

arkrypt@arkrypt-linux:~$ sudo rsync -ave esxi02-b:/vmfs/volumes/54ef4c22-27a271ae-b5c4-000af77e3720/ASTRABESSVEEAM/ /media/arkrypt/db154dfe-6497-4cf1-a782-60ba9476235f/bakhak
sending incremental file list
drwxrwxrwx 4,096 2016/04/07 13:57:54 bakhak

sent 70 bytes received 74 bytes 288.00 bytes/sec
total size is 0 speedup is 0.00

I see nothing in the bakhak folder.

What is happening?
 
Old 04-08-2016, 10:38 AM   #25
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,295
Blog Entries: 3

Rep: Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719
Does the source directory have files in it?

sudo is not needed and should be avoided so that rsync is not run as root, if you have set up your backup destination to not need root. If (for now) you want to point to root account on the remote machine, then put it in the host specification.

rsync -av root@esxi02-b:/vmfs/volumes/54ef4c22-27a271ae-b5c4-000af77e3720/ASTRABESSVEEAM/ /media/arkrypt/db154dfe-6497-4cf1-a782-60ba9476235f/bakhak/

Later, when you have keys you will use -e to specify which key, but rsync needs to work by itself.

Last edited by Turbocapitalist; 04-08-2016 at 10:43 AM.
 
Old 04-26-2016, 02:05 PM   #26
biosboy4
Member
 
Registered: Aug 2015
Distribution: Debian, SUSE, NXOS
Posts: 242

Original Poster
Rep: Reputation: 38
I finally got everything working!

I used a pull script to pull backup all FILES from the network. Then I used a second script that runs from the ESXi host to push the vms over. I used XSIbackup (open source/free) for this, which supports many things including hot backups.

Here's what ended up working:

#Hardware: x86 box with a good raid config (like raid 1 or 10).
#I used 4 partitions for this deployment: OS(small), Dir1"sdd1" (big), Dir2 "sdd2" (bigger), and vault"sdc" (biggest).
#Software: Debian, dependencies are pretty much met out of the box. You will need Rsync and Samba if you made a minimal install.
#XSi-Backup, a respected open source backup solution that supports hot-running vm backups. Installation is spelled out in this script.
#Connect the server to the network via a static IP, make sure it can ping everything it needs to reach.
#make sure sdc is umounted by default, sdd1 is mounted to /backup/Dir1, and sdd2 is mounted to /backup/Dir2
#run the script:

mount -t cifs //serverip/sharedir/ /backup/dir1 -o credentials=/credentialslocation
#this mounts the entire shared drive using a root read only credentials file
sleep 10s

rsync -avz /backup/dir1/ /backup/dir2
#backs up the data from dir1 to dir2
sleep 10s

umount /backup/dir1
#unmounts windows share
sleep 10s

mount -t //server/"share with spaces"/ backup/dir1 -o credentials=/credentialslocation
#Mount the PLC share
sleep 10s

rsync -avz /backup/dir1 /backup/dir2
#syncs share to dir2
#note* an "infinite" amount of directories can be backed up this way
sleep 10s

umount /backup/dir1
#unmounts share
sleep 20s

freshclam
#antivirus update
sleep 10s

clamscan -r --bell -i /
#scan entire filesystem and hault/ring a bell (alert) upon threat detection, stopping the script.
sleep 10s


mount /dev/sdc /backup/vault
#mounts the backup vault
sleep 10s

rsync -avz /backup/dir2/ /mnt/bak8
#syncs temp dir2 to the vault
sleep 10s

umount /mnt/bak8
#unmounts vault
sleep 10s

#end of script.

Here's how I got the vms backed up:

install XSibackup:
cd /vmfs/volumes/datastore1/xsi-dir 2>/dev/null || mkdir /vmfs/volumes/datastore1/xsi-dir && \
cd /vmfs/volumes/datastore1/xsi-dir && \
esxcli network firewall unload && \
wget http://33hops.com/downloads/?key=ojW...ziaiJYXquxoIaR -O xsibackup.zip && \
unzip -o xsibackup.zip && \
chmod 0700 xsibackup* && \
rm -rf xsibackup.zip && \
esxcli network firewall load

Now set up Dir2 on the server as an NFS share to be mounted via the ESXi cli or vsphere.

Now we cron this script:

./xsibackup --backup-point=/vmfs/volumes/newnfsdatastore --backup-type=ALL
#this pushes clones of the hot and cold vms directly to the backup server where it will pick them up from Dir2 and drop them into the vault automatically.

This is the rough draft/launch of this little project. I have a lot of cleaning up to do and many improvements to make. Any help is greatly appreciated.

Thanks,

Last edited by biosboy4; 04-26-2016 at 03:39 PM.
 
Old 04-26-2016, 02:20 PM   #27
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,295
Blog Entries: 3

Rep: Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719
Great!

At first glance it would be important to make provisions for situations where a mount or unmount fails. Maybe some if the other actions need that as well. One way might be to launch the whole script with "#!/bin/sh -e" so that the script exits if an untested command fails. Another might be to test some of the commands with || and provide an alternate action. Or do a little of both.
 
Old 04-26-2016, 02:33 PM   #28
biosboy4
Member
 
Registered: Aug 2015
Distribution: Debian, SUSE, NXOS
Posts: 242

Original Poster
Rep: Reputation: 38
Oh that sounds cool, so what might that kind of Bash-Fu look like?

Edit: I'm already getting umount fails from time to time telling me that the /dev/sdxx is busy, so adding those kinds of things to the script is definitely interesting. I am listening.

Last edited by biosboy4; 04-26-2016 at 02:34 PM.
 
Old 04-26-2016, 02:42 PM   #29
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,295
Blog Entries: 3

Rep: Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719
bash should take the same -e option, check the manual page for bash to see that and other goodies.

Code:
man bash
The test can look like this, but with another program of your choice than shutdown

Code:
mount /dev/sdc /backup/vault  || shutdown -h now 'run in circles, scream and shout'
The general structure can be seen by testing with true and false:

Code:
true  || echo not OK
false || echo not OK
or even

Code:
true  && echo OK || echo not OK
false && echo OK || echo not OK
 
Old 04-26-2016, 03:29 PM   #30
biosboy4
Member
 
Registered: Aug 2015
Distribution: Debian, SUSE, NXOS
Posts: 242

Original Poster
Rep: Reputation: 38
I'm 100% not following you, lol.

Keep in mind that I am a Bash noob.

lol
 
  


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
Looking for Open Source SAN or LUN Backup Solution DukeLeto Linux - Software 4 04-22-2011 01:05 PM
Open Source File Replication/backup solution needed jeveretts Linux - Newbie 5 06-06-2010 11:19 AM
Open source backup solution ShaqDiesel Linux - Newbie 3 08-30-2008 03:53 PM
Open Source Backup Solution? jedimastermopar Linux - Server 8 06-03-2008 06:42 AM
LXer: Set up a MySQL backup solution in 15 minutes! (all using open source bits) LXer Syndicated Linux News 1 10-30-2006 04:44 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 12:37 PM.

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