NAUbackup / VmBackup

XenServer simple backup script
228 stars 61 forks source link

Doesn't seem to work for CIFS #19

Open Nantris opened 8 years ago

Nantris commented 8 years ago

I know the script says it works for CIFS, but I've tried the formats for both the NFS and CIFS DEFAULT_BACKUP_DIR to connect to a FreeNAS CIFS and a Windows 7 share and I always get "ERROR: config backup_dir does not exist"

Is there something simple I'm overlooking here, or is it really a bug? I'm not sure.

Nantris commented 8 years ago

I was able to get it working by using the NFS format and using /var/run/sr-mount/, never with the CIFS format.

NAUbackup commented 8 years ago

Note that there is a slight change you have to make in the code to accommodate SMB/CIFS mounts. Did you do that? It's in the documentation.

Nantris commented 8 years ago

Hey thanks for checking in!

I did comment out the NFS line and uncomment the SMB line with the slightly different format and attempted to use that. I don't see any more instructions than to do that in the documentation. Am I overlooking a part?

Thanks again!

NAUbackup commented 8 years ago

That really should be it. Do you have a firewall or other access limitation between your SMB storage and XenServer(s)? If you could pass along an error message or error log entry, that would be helpful.

Nantris commented 8 years ago
2016-05-24-(10:30:04) - VmBackup config loaded from: God001
2016-05-24-(10:30:04) - VmBackup.py running with these settings:
2016-05-24-(10:30:04) -   backup_dir        = \Backups\VM-Images
2016-05-24-(10:30:04) -   compress          = False
2016-05-24-(10:30:04) -   max_backups       = 4
2016-05-24-(10:30:04) -   vdi_export_format = raw
2016-05-24-(10:30:04) -   pool_db_backup    = 1
2016-05-24-(10:30:04) -   exclude (cnt)= 0
2016-05-24-(10:30:04) -   exclude:
2016-05-24-(10:30:04) -   vdi-export (cnt)= 0
2016-05-24-(10:30:04) -   vdi-export:
2016-05-24-(10:30:04) -   vm-export (cnt)= 1
2016-05-24-(10:30:04) -   vm-export: God001
ERROR: config backup_dir does not exist -> \Backups\VM-Images
2016-05-24-(10:30:04) - ERROR in configuration settings...

As far as I can tell it doesn't attempt to write to the log because it fails very early. The VmBackup.py is running from the Xenserver Pool Host and in the context above 'Backups' is the name of the SR in XenCenter. Is that what it should be?

This could be an issue of me misunderstanding the instructions. I tried a bunch of different ways with no luck.

As I mentioned I got it working by using the /var/run/sr-mount workaround, but I'd be glad to help you troubleshoot this (if it's a real issue)

The device we're backing up to is a FreeNAS device, the CIFS shares work completely normally everywhere I've seen, but just so you have all the details.

davisko commented 8 years ago

As far as I understand, the target backup location does not need to be an SR. Instead, try mounting the target location directly to the Dom0 local filesystem. In fact, using an SR may not be very safe, because what would happen if you later created a virtual disk in the SR on accident? I have a VM that is being used as an NFS/CIFS fileserver that is hosting the location for backups, and have successfully used both NFS and CIFS mounts. However, I only have stand-alone XS servers, that are not pooled.

Nantris commented 8 years ago

I see where you're coming from, but because the CIFS SR is mounted as an ISO Library it can't be written to from XenCenter so the risk of accidentally messing up the repository is very low. (I'm the sole IT admin for the system)

NAUbackup commented 8 years ago

The target backup device should in fact not be on a XenServer at all -- you want to have your backups somewhere preferably totally separate from any XenServer environment. We use NFS. If using SMB, should also not be shared with another CIFS device or confusion may take place, especially not with an ISO mount, which is handled differently and is mounted RO, anyway. And as davisko states above, we also mount directly to a mount point on dom0 on all the servers so the path is the same everywhere.

Nantris commented 8 years ago

The backup device is a FreeNAS device which has a writable CIFS share, but it is mounted as an ISO SR in XenCenter.

If I wanted to mount it directly like you are your NFS, how can I do that? I'm not familiar with mounting CIFS shares to dom0 and I try to avoid working outside the Citrix provided solutions as much as possible. Can you point me in the right direction on how to do that? Then I can report back if the issue is a real issue or a mistake on my part.

By the way my method has been working great so far. That's what plenty of people say right before things explode of course, but right now I'm not very concerned.

NAUbackup commented 8 years ago

https://wiki.samba.org/index.php/Mounting_samba_shares_from_a_unix_client

verus001 commented 8 years ago

I have a directory shared on a windows computer (iSCSI NAS) and mounted. I can also write (make files and directories) from the xenserver into the directory

but I get ERROR: config backup_dir does not exist -> \snapshots\BACKUPS

[root@xenvars NAUbackup]# ./VmBackup.py XXXXX example.cfg preview 2016-06-09-(12:25:42) - VmBackup config loaded from: example.cfg 2016-06-09-(12:25:42) - VmBackup.py running with these settings: 2016-06-09-(12:25:42) - backup_dir = \snapshots\BACKUPS 2016-06-09-(12:25:42) - compress = False 2016-06-09-(12:25:42) - max_backups = 2 2016-06-09-(12:25:42) - vdi_export_format = raw 2016-06-09-(12:25:42) - pool_db_backup = 0 2016-06-09-(12:25:42) - exclude (cnt)= 0 2016-06-09-(12:25:42) - exclude: 2016-06-09-(12:25:42) - vdi-export (cnt)= 1 2016-06-09-(12:25:42) - vdi-export: 6006BLL 2016-06-09-(12:25:42) - vm-export (cnt)= 0 2016-06-09-(12:25:42) - vm-export: ERROR: config backup_dir does not exist -> \snapshots\BACKUPS 2016-06-09-(12:25:42) - ERROR in configuration settings...

Configured for CIFS: DEFAULT_BACKUP_DIR = '\snapshots\BACKUPS'

MOUNT: //192.168.6.13/XEN_backups on /snapshots/BACKUPS type cifs (rw)

When I use DEFAULT_BACKUP_DIR = '/snapshots/BACKUPS' it creates the backup directory for the VM but then stops:

[root@xenvars NAUbackup]# ./VmBackup.py XXXXX example.cfg preview 2016-06-09-(12:27:31) - VmBackup config loaded from: example.cfg 2016-06-09-(12:27:31) - VmBackup.py running with these settings: 2016-06-09-(12:27:31) - backup_dir = /snapshots/BACKUPS 2016-06-09-(12:27:31) - compress = False 2016-06-09-(12:27:31) - max_backups = 2 2016-06-09-(12:27:31) - vdi_export_format = raw 2016-06-09-(12:27:31) - pool_db_backup = 0 2016-06-09-(12:27:31) - exclude (cnt)= 0 2016-06-09-(12:27:31) - exclude: 2016-06-09-(12:27:31) - vdi-export (cnt)= 1 2016-06-09-(12:27:31) - vdi-export: 6006BLL 2016-06-09-(12:27:31) - vm-export (cnt)= 0 2016-06-09-(12:27:31) - vm-export: 2016-06-09-(12:27:31) - SUCCESS preview parameters

[root@xenvars NAUbackup]# ./VmBackup.py XXXXX example.cfg 2016-06-09-(12:28:23) - VmBackup config loaded from: example.cfg 2016-06-09-(12:28:23) - VmBackup.py running with these settings: 2016-06-09-(12:28:23) - backup_dir = /snapshots/BACKUPS 2016-06-09-(12:28:23) - compress = False 2016-06-09-(12:28:23) - max_backups = 2 2016-06-09-(12:28:23) - vdi_export_format = raw 2016-06-09-(12:28:23) - pool_db_backup = 0 2016-06-09-(12:28:23) - exclude (cnt)= 0 2016-06-09-(12:28:23) - exclude: 2016-06-09-(12:28:23) - vdi-export (cnt)= 1 2016-06-09-(12:28:23) - vdi-export: 6006BLL 2016-06-09-(12:28:23) - vm-export (cnt)= 0 2016-06-09-(12:28:23) - vm-export: 2016-06-09-(12:28:24) - =========================== 2016-06-09-(12:28:24) - VmBackup running on xenvars ... 2016-06-09-(12:28:24) - Space before backups: df -Th /snapshots/BACKUPS 2016-06-09-(12:28:24) - Filesystem Type Size Used Avail Use% Mounted on 2016-06-09-(12:28:24) - //192.168.6.13/XEN_backups 2016-06-09-(12:28:24) - cifs 11T 436M 11T 1% /snapshots/BACKUPS 2016-06-09-(12:28:24) - ****** vdi-export= *** 2016-06-09-(12:28:24) - *\ vdi-export begin 6006BLL 2016-06-09-(12:28:24) - vdi-export - vm_name: 6006BLL maxbackups: 2 not all arguments converted during string formatting 2016-06-09-(12:28:24) - ERROR EXCEPTION - exceptions.TypeError 2016-06-09-(12:28:24) - _ERROR NOTE: see VmBackup output for details Traceback (most recent call last): File "./VmBackup.py", line 1362, in ? main(session) File "./VmBackup.py", line 122, in main full_backup_dir = process_backup_dir(vm_backup_dir) File "./VmBackup.py", line 654, in process_backup_dir return create_full_backup_dir(tmp_vm_backup_dir) File "./VmBackup.py", line 664, in create_full_backup_dir tmp_backup_dir = BACKUP_DIR_PATTERN \ TypeError: not all arguments converted during string formatting

seems like a bug ?? And why do you on a linux computer use "\" ?? When the drive is mounted, you just go to the directory using the "/", I don't understand the meaning of that.

verus001 commented 8 years ago

I shared the directory on the windows server as NFS but I still get an error:

[root@xenvars NAUbackup]# ./VmBackup.py XXXXX example.cfg 2016-06-09-(15:10:58) - VmBackup config loaded from: example.cfg 2016-06-09-(15:10:58) - VmBackup.py running with these settings: 2016-06-09-(15:10:58) - backup_dir = /snapshots/BACKUPS 2016-06-09-(15:10:58) - compress = False 2016-06-09-(15:10:58) - max_backups = 2 2016-06-09-(15:10:58) - vdi_export_format = raw 2016-06-09-(15:10:58) - pool_db_backup = 0 2016-06-09-(15:10:58) - exclude (cnt)= 0 2016-06-09-(15:10:58) - exclude: 2016-06-09-(15:10:58) - vdi-export (cnt)= 1 2016-06-09-(15:10:58) - vdi-export: 6006BLL 2016-06-09-(15:10:58) - vm-export (cnt)= 0 2016-06-09-(15:10:58) - vm-export: 2016-06-09-(15:10:58) - =========================== 2016-06-09-(15:10:58) - VmBackup running on xenvars ... 2016-06-09-(15:10:58) - Space before backups: df -Th /snapshots/BACKUPS 2016-06-09-(15:10:58) - Filesystem Type Size Used Avail Use% Mounted on 2016-06-09-(15:10:58) - 192.168.6.13:/XEN_backups 2016-06-09-(15:10:58) - nfs 11T 436M 11T 1% /snapshots/BACKUPS 2016-06-09-(15:10:58) - ****** vdi-export= *** 2016-06-09-(15:10:58) - *\ vdi-export begin 6006BLL 2016-06-09-(15:10:58) - vdi-export - vm_name: 6006BLL maxbackups: 2 not all arguments converted during string formatting 2016-06-09-(15:10:58) - ERROR EXCEPTION - exceptions.TypeError 2016-06-09-(15:10:58) - _ERROR NOTE: see VmBackup output for details Traceback (most recent call last): File "./VmBackup.py", line 1362, in ? main(session) File "./VmBackup.py", line 122, in main full_backup_dir = process_backup_dir(vm_backup_dir) File "./VmBackup.py", line 654, in process_backup_dir return create_full_backup_dir(tmp_vm_backup_dir) File "./VmBackup.py", line 664, in create_full_backup_dir tmp_backup_dir = BACKUP_DIR_PATTERN \ TypeError: not all arguments converted during string formatting [root@xenvars NAUbackup]#

davisko commented 8 years ago

Post contents of example.cfg

verus001 commented 8 years ago

I tried to start the backup without the example.cfg also and that didn't make a difference (now with the NFS settings):

./VmBackup.py XXXXX 6006BLL

[root@xenvars NAUbackup]# ./VmBackup.py XXXXX 6006BLL 2016-06-10-(09:28:19) - VmBackup config loaded from: 6006BLL 2016-06-10-(09:28:19) - VmBackup.py running with these settings: 2016-06-10-(09:28:19) - backup_dir = /snapshots/BACKUPS 2016-06-10-(09:28:19) - compress = False 2016-06-10-(09:28:19) - max_backups = 4 2016-06-10-(09:28:19) - vdi_export_format = raw 2016-06-10-(09:28:19) - pool_db_backup = 0 2016-06-10-(09:28:19) - exclude (cnt)= 0 2016-06-10-(09:28:19) - exclude: 2016-06-10-(09:28:19) - vdi-export (cnt)= 0 2016-06-10-(09:28:19) - vdi-export: 2016-06-10-(09:28:19) - vm-export (cnt)= 1 2016-06-10-(09:28:19) - vm-export: 6006BLL 2016-06-10-(09:28:19) - =========================== 2016-06-10-(09:28:19) - VmBackup running on xenvars ... 2016-06-10-(09:28:19) - Space before backups: df -Th /snapshots/BACKUPS 2016-06-10-(09:28:19) - Filesystem Type Size Used Avail Use% Mounted on 2016-06-10-(09:28:19) - 192.168.6.13:/XEN_backups 2016-06-10-(09:28:19) - nfs 11T 526M 11T 1% /snapshots/BACKUPS 2016-06-10-(09:28:19) - \ vdi-export= *** 2016-06-10-(09:28:19) - ** vm-export= ***** 2016-06-10-(09:28:19) - *\ vm-export begin 6006BLL 2016-06-10-(09:28:19) - vm-export - vm_name: 6006BLL maxbackups: 4 not all arguments converted during string formatting 2016-06-10-(09:28:19) - ERROR EXCEPTION - exceptions.TypeError 2016-06-10-(09:28:19) - _ERROR NOTE: see VmBackup output for details Traceback (most recent call last): File "./VmBackup.py", line 1362, in ? main(session) File "./VmBackup.py", line 296, in main full_backup_dir = process_backup_dir(vm_backup_dir) File "./VmBackup.py", line 654, in process_backup_dir return create_full_backup_dir(tmp_vm_backup_dir) File "./VmBackup.py", line 664, in create_full_backup_dir tmp_backup_dir = BACKUP_DIR_PATTERN \ TypeError: not all arguments converted during string formatting

Content of example.cfg:

Copyright (C) 2016 Northern Arizona University

This program is free software: you can redistribute it and/or modify

it under the terms of the GNU General Public License as published by

the Free Software Foundation, either version 3 of the License, or

(at your option) any later version.

This program is distributed in the hope that it will be useful,

but WITHOUT ANY WARRANTY; without even the implied warranty of

MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

GNU General Public License for more details.

You should have received a copy of the GNU General Public License

along with this program. If not, see http://www.gnu.org/licenses/.

Title: NAUbackup / VmBackup - a XenServer vm-export and vdi-export Backup Script

Package Contents: README, VmBackup.py, example.cfg (this file)

Example config file for VmBackup.py

high level VmBackup settings

note - if any of these are not specified

then VmBackup has default constants

Take Xen Pool DB backup: 0=No, 1=Yes (script default to 0=No)

pool_db_backup=0

How many backups to keep for each vm (script default to 4)

max_backups=2

Backup Directory path (script default /snapshots/BACKUPS)

backup_dir=/path/to/backupspace

backup_dir=/snapshots/BACKUPS

applicable if vdi-export is used

vdi_export_format either raw or vhd (script default to raw)

vdi_export_format=raw

specific VMs backup settings

vm-export VM name-label of vm to backup. One per line - notice :max_backups override.

vm-export=my-vm-name

vm-export=my-second-vm

vm-export=my-third-vm:3

vm-export=6006BLL

special vdi-export - only backs up first disk. See README Documenation!

vdi-export=my-vm-name

vdi-export=6006BLL

vm-export using VM prefix wildcard - notice DEV* has :max_backups overide

vm-export=PROD*

vm-export=DEV*:2

vm-export=6006BLL

exclude selected VMs from VM prefix wildcards

exclude=PROD-WinDomainController

exclude=DEV-DestructiveTest

exclude=2008BLL

verus001 commented 8 years ago

no updates ? is this program still in beta phase ? thanks.

NAUbackup commented 8 years ago

Looks like you may have a space somewhere in your configuration file or VM name that either needs to be deleted or escaped/quoted. Did you try running in the debug mode?

Nantris commented 8 years ago

I tried just about everything I could come up with. The system is in production now using a Storage Repo workaround I found, so until we upgrade to XenServer 7 I'm going to let it run with my workaround instead.

On Wed, Sep 7, 2016 at 4:42 AM, NAUbackup notifications@github.com wrote:

Looks like you may have a space somewhere in your configuration file or VM name that either needs to be deleted or escaped/quoted. Did you try running in the debug mode?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/NAUbackup/VmBackup/issues/19#issuecomment-245214839, or mute the thread https://github.com/notifications/unsubscribe-auth/AGhOswcLctAcfGA_KfHzzVCrVerEs50Tks5qnnkQgaJpZM4IdOQ6 .

NAUbackup commented 7 years ago

@Slapbox -- did that ever work out for you? Sorry about the exceedingly slow response time here.