Re: [Bacula-users] How to remove all volumes?

2022-03-21 Thread Justin Case
Thank you Chris and Martin!

What I then did was use the Baculum Volumes view, filter for all volumes that 
are not purged and set them to Purged. It is easier in Baculum than I initially 
thought.
Then I used a job to run: truncate volume allpools storage=mystorage 

That was easy enough for me, but it is great to have Chris’es scripts now!

All the best
JC


> On 21. Mar 2022, at 16:48, Chris Wilkinson  wrote:
> 
> I wrote a couple of scripts to help with this problem. Start by deleting all 
> the jobs that you don’t want anymore. This should mark all the associated 
> volumes as ‘purged’. That can be done in bconsole or Baculum.
> 
> This one deletes any ‘purged’ volume records from the catalog.
> 
> #!/bin/bash
> #Usage: sudo ./delete-purged-volumes.sh any-char
> #Delete purged Bacula volumes. Do not delete if arg is empty
> if [[ -z $1 ]]; then
>   echo "Not deleting"
> fi
> for vol in $(echo "list volume" | bconsole | grep Purged | awk '{print $4}')
> do
>   if [[ ! -z $1 ]]; then
> echo "delete yes volume=$vol" | bconsole > /dev/null
> echo "Volume $vol deleted"
>   else
> echo "Volume $vol not deleted"
>   fi
> done
> 
> This one deletes any volumes from the filesystem that are not now in the 
> catalog. These are files in the filesystem that have no entry in the catalog.
> 
> #!/bin/bash
> #Usage: sudo -u bacula ./delete-orphened-volumes.sh target-dir any-char
> #Delete orphaned Bacula volumes. Do not delete if second arg is empty
> if [[ -z $1 ]]; then
>   echo "Please supply target directory"
>   exit
> fi
> if [[ ! -d $1 ]]; then
>   echo "Target does not exist"
>   exit
> fi
> if [[ -z $2 ]]; then
>   echo "Not deleting"
> fi
> cd $1  # change to target directory
> for vol in $(find . -maxdepth 1 -type f -printf '%f\n')
> do
>   echo "list volume=$vol" | bconsole | if grep --quiet "No results to list"; 
> then
> if [[ ! -z $2 ]]; then
>   rm $1$vol
>   echo "Orphaned file $1$vol deleted"
> else
>   echo "Orphaned file $1$vol not deleted"
> fi
>   fi
> done
> 
> Best
> -Chris-
> 
> 
> 
> 
>> On 21 Mar 2022, at 12:42, Martin Simmons > > wrote:
>> 
>> You can use the "delete volume" command in bconsole to remove a volume from
>> the catalog.  After that, you can safely rm it from the filesystem.
>> 
>> __Martin
>> 
>> 
>>> On Sat, 19 Mar 2022 13:08:41 +0100, Justin Case said:
>>> 
>>> Dear all,
>>> 
>>> again another newbie question:
>>> 
>>> I need to use a different disk drive for Bacula and I would like to start 
>>> over in the sense of deleting all volume files in a clean way, i.e. not 
>>> corrupting the catalog. The goal is to free up the space occupied by all 
>>> Bacula volumes.
>>> 
>>> I know that I could migrate all volumes, but that takes more time than 
>>> starting over. Losing all backups of the past few days after setting up 
>>> Bacula is OK for me.
>>> 
>>> I checked the manual what else I could do and it seems that one way would 
>>> be to set each volume manually to purged, but that would not delete the 
>>> volume but it would just be recycled/re-used. That would basically not help 
>>> me to free the space on the disk currently used by Bacula. Also it would be 
>>> a manual effort as I already have >150 volumes.
>>> 
>>> All the best,
>>> JC
>>> 
>>> 
>>> 
>>> 
>>> 
>>> ___
>>> Bacula-users mailing list
>>> Bacula-users@lists.sourceforge.net 
>>> 
>>> https://lists.sourceforge.net/lists/listinfo/bacula-users
>>> 
>> 
>> 
>> ___
>> Bacula-users mailing list
>> Bacula-users@lists.sourceforge.net 
>> 
>> https://lists.sourceforge.net/lists/listinfo/bacula-users
> 

___
Bacula-users mailing list
Bacula-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-users


Re: [Bacula-users] How to remove all volumes?

2022-03-21 Thread Chris Wilkinson
I wrote a couple of scripts to help with this problem. Start by deleting all 
the jobs that you don’t want anymore. This should mark all the associated 
volumes as ‘purged’. That can be done in bconsole or Baculum.

This one deletes any ‘purged’ volume records from the catalog.

#!/bin/bash
#Usage: sudo ./delete-purged-volumes.sh any-char
#Delete purged Bacula volumes. Do not delete if arg is empty
if [[ -z $1 ]]; then
  echo "Not deleting"
fi
for vol in $(echo "list volume" | bconsole | grep Purged | awk '{print $4}')
do
  if [[ ! -z $1 ]]; then
echo "delete yes volume=$vol" | bconsole > /dev/null
echo "Volume $vol deleted"
  else
echo "Volume $vol not deleted"
  fi
done

This one deletes any volumes from the filesystem that are not now in the 
catalog. These are files in the filesystem that have no entry in the catalog.

#!/bin/bash
#Usage: sudo -u bacula ./delete-orphened-volumes.sh target-dir any-char
#Delete orphaned Bacula volumes. Do not delete if second arg is empty
if [[ -z $1 ]]; then
  echo "Please supply target directory"
  exit
fi
if [[ ! -d $1 ]]; then
  echo "Target does not exist"
  exit
fi
if [[ -z $2 ]]; then
  echo "Not deleting"
fi
cd $1  # change to target directory
for vol in $(find . -maxdepth 1 -type f -printf '%f\n')
do
  echo "list volume=$vol" | bconsole | if grep --quiet "No results to list"; 
then
if [[ ! -z $2 ]]; then
  rm $1$vol
  echo "Orphaned file $1$vol deleted"
else
  echo "Orphaned file $1$vol not deleted"
fi
  fi
done

Best
-Chris-




> On 21 Mar 2022, at 12:42, Martin Simmons  wrote:
> 
> You can use the "delete volume" command in bconsole to remove a volume from
> the catalog.  After that, you can safely rm it from the filesystem.
> 
> __Martin
> 
> 
>> On Sat, 19 Mar 2022 13:08:41 +0100, Justin Case said:
>> 
>> Dear all,
>> 
>> again another newbie question:
>> 
>> I need to use a different disk drive for Bacula and I would like to start 
>> over in the sense of deleting all volume files in a clean way, i.e. not 
>> corrupting the catalog. The goal is to free up the space occupied by all 
>> Bacula volumes.
>> 
>> I know that I could migrate all volumes, but that takes more time than 
>> starting over. Losing all backups of the past few days after setting up 
>> Bacula is OK for me.
>> 
>> I checked the manual what else I could do and it seems that one way would be 
>> to set each volume manually to purged, but that would not delete the volume 
>> but it would just be recycled/re-used. That would basically not help me to 
>> free the space on the disk currently used by Bacula. Also it would be a 
>> manual effort as I already have >150 volumes.
>> 
>> All the best,
>> JC
>> 
>> 
>> 
>> 
>> 
>> ___
>> Bacula-users mailing list
>> Bacula-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/bacula-users
>> 
> 
> 
> ___
> Bacula-users mailing list
> Bacula-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/bacula-users

___
Bacula-users mailing list
Bacula-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-users


Re: [Bacula-users] How to remove all volumes?

2022-03-21 Thread Martin Simmons
You can use the "delete volume" command in bconsole to remove a volume from
the catalog.  After that, you can safely rm it from the filesystem.

__Martin


> On Sat, 19 Mar 2022 13:08:41 +0100, Justin Case said:
> 
> Dear all,
> 
> again another newbie question:
> 
> I need to use a different disk drive for Bacula and I would like to start 
> over in the sense of deleting all volume files in a clean way, i.e. not 
> corrupting the catalog. The goal is to free up the space occupied by all 
> Bacula volumes.
> 
> I know that I could migrate all volumes, but that takes more time than 
> starting over. Losing all backups of the past few days after setting up 
> Bacula is OK for me.
> 
> I checked the manual what else I could do and it seems that one way would be 
> to set each volume manually to purged, but that would not delete the volume 
> but it would just be recycled/re-used. That would basically not help me to 
> free the space on the disk currently used by Bacula. Also it would be a 
> manual effort as I already have >150 volumes.
> 
> All the best,
>  JC
> 
> 
> 
> 
> 
> ___
> Bacula-users mailing list
> Bacula-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/bacula-users
> 


___
Bacula-users mailing list
Bacula-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-users


Re: [Bacula-users] How to remove all volumes?

2022-03-19 Thread Justin Case
in bconsole: list volume (or list media) display that the volumes are still 
marked as Used, not as Purged. So I guess none of the commands I tried (see 
below) did achieve that the volumes were marked as Purged.

What is the right way to do that (without manually iterating through all volume 
names or IDs)?

> On 19. Mar 2022, at 22:20, Justin Case  wrote:
> 
> I think I am not good enough on bconsole yet, I tried different things but I 
> am getting nowhere.
> 
> Things I tried in bconsole:
> 
> (a) "purge action=truncate", then selected "2" for jobs
>  it tells me it purged a number of jobs, but no volume got truncated
> 
> (b) "purge volume action=truncate allpools storage=unraid-tier1-storage”
>  I get: No Volumes found to perform the command.
> 
> (c) truncate, then selected the storage and a pool,
> I get: No Volumes found to perform the command.
> 
> (d) truncate pool=unraid-minio-full storage=unraid-tier1-storage
> I get: No Volumes found to perform the command.
> 
> Something that would not work for me is if I had to manually enumerate each 
> volume to be purged and truncated (as there are just too many).
> 
> Could someone please help me out giving more detailed directions which 
> command(s) to run in bconsole with what parameters?
> 
>> On 19. Mar 2022, at 21:30, Heitor Faria  wrote:
>> 
>> Hello Justin,
>> 
>>> Or asked differently: Is it possible to declare all volumes as expired 
>>> without
>>> having to execute a command for each existing volume individually? 
>>> (something
>>> like “set all volumes to expired”)?
>> 
>> You can use the purge command to recycle the desired volumes prematurely. 
>> 
>> Rgds.
>> -- 
>> MSc Heitor Faria (Miami/USA) 
>> Bacula LATAM CIO 
>> 
>> mobile1: + 1 909 655-8971 
>> mobile2: + 55 61 98268-4220 
>> [ https://www.linkedin.com/in/msc-heitor-faria-5ba51b3 ] 
>>  [ http://www.bacula.com.br/ ] 
>> 
>> América Latina 
>> [ http://bacula.lat/ | bacula.lat ] | [ http://www.bacula.com.br/ | 
>> bacula.com.br ]
>> 
> 



___
Bacula-users mailing list
Bacula-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-users


Re: [Bacula-users] How to remove all volumes?

2022-03-19 Thread Justin Case
I read up the console manual on the purge command and also looked at help purge.
The tried:
(e) purge action=truncate allpools storage=unraid-tier1-storage
  when asked for a pool I selected a small one that is the on disk and I 
get a list of 2 volumes. When entering a media id I get this:
  Enter a Volume name or *MediaId: 46 
  sql_get.c:1337 Media record for Volume name "46" not found.

Sounds kinda wrong to me, as it was listing this volume right beforehand.

What am I doing wrong?

> On 19. Mar 2022, at 22:20, Justin Case  wrote:
> 
> I think I am not good enough on bconsole yet, I tried different things but I 
> am getting nowhere.
> 
> Things I tried in bconsole:
> 
> (a) "purge action=truncate", then selected "2" for jobs
>  it tells me it purged a number of jobs, but no volume got truncated
> 
> (b) "purge volume action=truncate allpools storage=unraid-tier1-storage”
>  I get: No Volumes found to perform the command.
> 
> (c) truncate, then selected the storage and a pool,
> I get: No Volumes found to perform the command.
> 
> (d) truncate pool=unraid-minio-full storage=unraid-tier1-storage
> I get: No Volumes found to perform the command.
> 
> Something that would not work for me is if I had to manually enumerate each 
> volume to be purged and truncated (as there are just too many).
> 
> Could someone please help me out giving more detailed directions which 
> command(s) to run in bconsole with what parameters?
> 
>> On 19. Mar 2022, at 21:30, Heitor Faria  wrote:
>> 
>> Hello Justin,
>> 
>>> Or asked differently: Is it possible to declare all volumes as expired 
>>> without
>>> having to execute a command for each existing volume individually? 
>>> (something
>>> like “set all volumes to expired”)?
>> 
>> You can use the purge command to recycle the desired volumes prematurely. 
>> 
>> Rgds.
>> -- 
>> MSc Heitor Faria (Miami/USA) 
>> Bacula LATAM CIO 
>> 
>> mobile1: + 1 909 655-8971 
>> mobile2: + 55 61 98268-4220 
>> [ https://www.linkedin.com/in/msc-heitor-faria-5ba51b3 ] 
>>  [ http://www.bacula.com.br/ ] 
>> 
>> América Latina 
>> [ http://bacula.lat/ | bacula.lat ] | [ http://www.bacula.com.br/ | 
>> bacula.com.br ]
>> 
> 



___
Bacula-users mailing list
Bacula-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-users


Re: [Bacula-users] How to remove all volumes?

2022-03-19 Thread Justin Case
I think I am not good enough on bconsole yet, I tried different things but I am 
getting nowhere.

Things I tried in bconsole:

(a) "purge action=truncate", then selected "2" for jobs
  it tells me it purged a number of jobs, but no volume got truncated

(b) "purge volume action=truncate allpools storage=unraid-tier1-storage”
  I get: No Volumes found to perform the command.

(c) truncate, then selected the storage and a pool,
 I get: No Volumes found to perform the command.

(d) truncate pool=unraid-minio-full storage=unraid-tier1-storage
 I get: No Volumes found to perform the command.

Something that would not work for me is if I had to manually enumerate each 
volume to be purged and truncated (as there are just too many).

Could someone please help me out giving more detailed directions which 
command(s) to run in bconsole with what parameters?

> On 19. Mar 2022, at 21:30, Heitor Faria  wrote:
> 
> Hello Justin,
> 
>> Or asked differently: Is it possible to declare all volumes as expired 
>> without
>> having to execute a command for each existing volume individually? (something
>> like “set all volumes to expired”)?
> 
> You can use the purge command to recycle the desired volumes prematurely. 
> 
> Rgds.
> -- 
> MSc Heitor Faria (Miami/USA) 
> Bacula LATAM CIO 
> 
> mobile1: + 1 909 655-8971 
> mobile2: + 55 61 98268-4220 
> [ https://www.linkedin.com/in/msc-heitor-faria-5ba51b3 ] 
>   [ http://www.bacula.com.br/ ] 
> 
> América Latina 
> [ http://bacula.lat/ | bacula.lat ] | [ http://www.bacula.com.br/ | 
> bacula.com.br ]
> 



___
Bacula-users mailing list
Bacula-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-users


Re: [Bacula-users] How to remove all volumes?

2022-03-19 Thread Heitor Faria
Hello Justin,

> Or asked differently: Is it possible to declare all volumes as expired without
> having to execute a command for each existing volume individually? (something
> like “set all volumes to expired”)?

You can use the purge command to recycle the desired volumes prematurely. 

Rgds.
-- 
MSc Heitor Faria (Miami/USA) 
Bacula LATAM CIO 

mobile1: + 1 909 655-8971 
mobile2: + 55 61 98268-4220 
[ https://www.linkedin.com/in/msc-heitor-faria-5ba51b3 ] 
[ http://www.bacula.com.br/ ] 

América Latina 
[ http://bacula.lat/ | bacula.lat ] | [ http://www.bacula.com.br/ | 
bacula.com.br ]


___
Bacula-users mailing list
Bacula-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-users


Re: [Bacula-users] How to remove all volumes?

2022-03-19 Thread Justin Case
Or asked differently: Is it possible to declare all volumes as expired without 
having to execute a command for each existing volume individually? (something 
like “set all volumes to expired”)?

> On 19. Mar 2022, at 20:30, Justin Case  wrote:
> 
> Thank you Heitor,
> 
> if I understand those directives correctly, it will only truncate expired 
> volumes. My volumes are by far not yet expired, still I want to truncate 
> them. Is that possible?
> 
> Best,
> JC
> 
>> On 19. Mar 2022, at 16:30, Heitor Faria  wrote:
>> 
>>> Dear all,
>> 
>> Hello Justin,
>> 
>>> I need to use a different disk drive for Bacula and I would like to start 
>>> over
>>> in the sense of deleting all volume files in a clean way, i.e. not 
>>> corrupting
>>> the catalog. The goal is to free up the space occupied by all Bacula 
>>> volumes.
>> 
>> Normally one user does not really need to free the volume space until the 
>> VolumeRetention is expired and the Volume is demanded by a new backup, but I 
>> understand some users might want to have better control of the current real 
>> necessary backup disk occupation to fulfill configured retentions.
>> Please refer to my small post: 
>> https://www.bacula.lat/truncate-bacula-volumes-to-free-disk-space/?lang=en
>> 
>>> All the best,
>> 
>> Regards,
>> 
>>> JC
>>> ___
>>> Bacula-users mailing list
>>> Bacula-users@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/bacula-users
>> 
>> -- 
>> MSc Heitor Faria (Miami/USA) 
>> Bacula LATAM CIO 
>> 
>> mobile1: + 1 909 655-8971 
>> mobile2: + 55 61 98268-4220 
>> [ https://www.linkedin.com/in/msc-heitor-faria-5ba51b3 ] 
>>  [ http://www.bacula.com.br/ ] 
>> 
>> América Latina 
>> [ http://bacula.lat/ | bacula.lat ] | [ http://www.bacula.com.br/ | 
>> bacula.com.br ]
>> 
> 



___
Bacula-users mailing list
Bacula-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-users


Re: [Bacula-users] How to remove all volumes?

2022-03-19 Thread Justin Case
Thank you Heitor,

if I understand those directives correctly, it will only truncate expired 
volumes. My volumes are by far not yet expired, still I want to truncate them. 
Is that possible?

Best,
 JC

> On 19. Mar 2022, at 16:30, Heitor Faria  wrote:
> 
>> Dear all,
> 
> Hello Justin,
> 
>> I need to use a different disk drive for Bacula and I would like to start 
>> over
>> in the sense of deleting all volume files in a clean way, i.e. not corrupting
>> the catalog. The goal is to free up the space occupied by all Bacula volumes.
> 
> Normally one user does not really need to free the volume space until the 
> VolumeRetention is expired and the Volume is demanded by a new backup, but I 
> understand some users might want to have better control of the current real 
> necessary backup disk occupation to fulfill configured retentions.
> Please refer to my small post: 
> https://www.bacula.lat/truncate-bacula-volumes-to-free-disk-space/?lang=en
> 
>> All the best,
> 
> Regards,
> 
>> JC
>> ___
>> Bacula-users mailing list
>> Bacula-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/bacula-users
> 
> -- 
> MSc Heitor Faria (Miami/USA) 
> Bacula LATAM CIO 
> 
> mobile1: + 1 909 655-8971 
> mobile2: + 55 61 98268-4220 
> [ https://www.linkedin.com/in/msc-heitor-faria-5ba51b3 ] 
>   [ http://www.bacula.com.br/ ] 
> 
> América Latina 
> [ http://bacula.lat/ | bacula.lat ] | [ http://www.bacula.com.br/ | 
> bacula.com.br ]
> 



___
Bacula-users mailing list
Bacula-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-users


Re: [Bacula-users] How to remove all volumes?

2022-03-19 Thread Heitor Faria
> Dear all,

Hello Justin,
 
> I need to use a different disk drive for Bacula and I would like to start over
> in the sense of deleting all volume files in a clean way, i.e. not corrupting
> the catalog. The goal is to free up the space occupied by all Bacula volumes.

Normally one user does not really need to free the volume space until the 
VolumeRetention is expired and the Volume is demanded by a new backup, but I 
understand some users might want to have better control of the current real 
necessary backup disk occupation to fulfill configured retentions.
Please refer to my small post: 
https://www.bacula.lat/truncate-bacula-volumes-to-free-disk-space/?lang=en
 
> All the best,

Regards,

> JC
> ___
> Bacula-users mailing list
> Bacula-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/bacula-users

-- 
MSc Heitor Faria (Miami/USA) 
Bacula LATAM CIO 

mobile1: + 1 909 655-8971 
mobile2: + 55 61 98268-4220 
[ https://www.linkedin.com/in/msc-heitor-faria-5ba51b3 ] 
[ http://www.bacula.com.br/ ] 

América Latina 
[ http://bacula.lat/ | bacula.lat ] | [ http://www.bacula.com.br/ | 
bacula.com.br ]


___
Bacula-users mailing list
Bacula-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-users


[Bacula-users] How to remove all volumes?

2022-03-19 Thread Justin Case
Dear all,

again another newbie question:

I need to use a different disk drive for Bacula and I would like to start over 
in the sense of deleting all volume files in a clean way, i.e. not corrupting 
the catalog. The goal is to free up the space occupied by all Bacula volumes.

I know that I could migrate all volumes, but that takes more time than starting 
over. Losing all backups of the past few days after setting up Bacula is OK for 
me.

I checked the manual what else I could do and it seems that one way would be to 
set each volume manually to purged, but that would not delete the volume but it 
would just be recycled/re-used. That would basically not help me to free the 
space on the disk currently used by Bacula. Also it would be a manual effort as 
I already have >150 volumes.

All the best,
 JC





___
Bacula-users mailing list
Bacula-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-users