IBM i Global

 View Only
Expand all | Collapse all

Archiving an IFS

  • 1.  Archiving an IFS

    Posted Wed April 20, 2022 08:47 AM
    Hi Everyone,

    Can someone please help me to archive an IFS in IBM i. I use the command CPYTOARCF, but the first parameter (From file or directory) is not allowing me to paste the complete IFS path which is (/vendors/saphanat/interface/ar/data/backup_in) due the the length. 

    Can someone guide me the step by step process to archive the IFS ? 

    Thanks
    Avinash

    ------------------------------
    Avinash Yadav
    ------------------------------


  • 2.  RE: Archiving an IFS

    Posted Wed April 20, 2022 10:08 AM
    Hi

    You may first type the command with the long 'fromfile' parameter before you press F4 to prompt the cmd. This will allow you to enter a much longer path ;-)
      CPYTOARCF FROMFILE('/your/veeeeeeeeeeeeeeeerrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrryyyyyyyyyyyyyyyyyyyyyyyyyyyy/long/path/name') -> F4

    Or use other tools to archive IFS objects like:
    * system save commands SAV DEV('/qsys.lib/my.lib/mysavf.file') ...
    * with jdk installe -> qsh cmd('java jar -cfM')
    * with open source support aktive (PASE and YUM) -> just install zip and unzip and use them with qsh
    * there may be other ways 

    Markus

    ------------------------------
    Markus Neuhold
    ------------------------------



  • 3.  RE: Archiving an IFS

    Posted Wed April 20, 2022 11:12 AM

    Just type the '&' character (without quotes) in the first position of the command field and press enter. The field will expand in length. You can do this more than one time.

     

     

    www.remainsoftware.com

    See our video to learn more about Remain.






  • 4.  RE: Archiving an IFS

    Posted Wed April 20, 2022 11:49 AM
    ThankYou, It worked. I have another issue with sorting the files. I have close to 2 lac objects inside /root/vendors/saphanat/interface/ar/data/backup_in directory. Hope you can see the screenshot attached.

    How can I sort out this objects by year and zip it in a new folder ?  Customer doesn't want to zip the directory, they want this objects to zip by year. 

    Appreciate all the help- Thanks.






  • 5.  RE: Archiving an IFS

    IBM Champion
    Posted Thu April 21, 2022 08:47 AM
    What I find sad is that exact screen you are using has an unzip option but not a zip option.  Check out Actions.
    This looks like a candidate for an "idea":  https://ideas.ibm.com/

    See if you can find an open source version of zip to install on IBM i so that you can do something like the following in qsHell or somesuch thing:
    zip -r /home/rob/test.zip $(find /home/rob -type f -mtime +500)
    where 500 is the number of days

    ------------------------------
    Robert Berendt
    ------------------------------



  • 6.  RE: Archiving an IFS

    Posted Thu April 21, 2022 09:29 AM
    Thanks, I will try that and post the same in ideas.

    One more concern I have is, If you see the below screenshot, that IFS has duplicates of DN.SD002.INS.20200
    those are in thousands. 

    1. How can I copy them in a separate folder ? Any way to copy them through SQL in a different folder ?








  • 7.  RE: Archiving an IFS

    IBM Champion
    Posted Thu April 21, 2022 09:59 AM
    Those aren't duplicates, that screen can only show you so many characters.  If you position on any one of them there will be a function key to display the whole name.  I think it is F22 aka Shift-F10.
    You can use a different interface, like the iACS you were using earlier, to see the whole name also.

    You can also use that GUI to:
    1. Create new directories, like 2020, 2021, ...
    2. Sort the list by date
    3. Copy all those created in 2020 and paste them into the folder 2020
    4. Delete those from the original directory
    Then you can use CPYTOARCF to zip up the new directories.

    ------------------------------
    Robert Berendt
    ------------------------------



  • 8.  RE: Archiving an IFS

    Posted Fri April 22, 2022 12:18 PM
    You can user Qsh jar to zip or unzip files






  • 9.  RE: Archiving an IFS

    Posted Thu April 21, 2022 11:15 AM
    @Avinash Yadav if it's a one-time job you may search for an AIX zip binary, then upload it in binary mode to your server. use qsh cmd('/path/2/zipfile/zip ....') to do the zip operation. 

    If you are planning to use it on a regular base, you should read yourself into https://ibmi-oss-docs.readthedocs.io/en/latest/README.html or https://ibm.github.io/ibmi-oss-resources/ (IBM i Open Source) and use YUM (or ACS) to install and update the zip binary for the PASE environment.

    Markus​​

    ------------------------------
    Markus Neuhold
    ------------------------------



  • 10.  RE: Archiving an IFS

    Posted Thu April 21, 2022 01:14 PM
    ThankYou everyone for the suggestions, but my issue now is segregating the objects under the below directory since my iACS gets crashed in the middle while populating all objects from the directory /backup_in. 
    As @Robert Berendt suggested to create a directory using iACS, but the issue is, when I access the IFS /vendors/saphanat/interface/ar/data/backup_in  using iACS, and when it starts to load all objects under backup_in, it gets crashed. I tried this multiple times and my ACS gets crashed everytime. There are close to 2 lacs objects under /backup_in. Below screenshot i took before my iACS crashed.


    Question : What are the other ways I can sort the list by date ?





  • 11.  RE: Archiving an IFS

    IBM Champion
    Posted Thu April 21, 2022 01:30 PM
    You could try
    EDTF '/vendors/saphanat/interface/ar/data/backup_i'
    position your cursor on a date
    Press F16 to sort by date.
    You're probably not going to like that though and the file names may still be truncated.

    Again, look at some of the open source methods.

    Or look at https://www.scottklement.com/rpg/ifs.html

    Or look at  IFS_OBJECT_STATISTICS table function - IBM Documentation

    ------------------------------
    Robert Berendt
    ------------------------------



  • 12.  RE: Archiving an IFS

    IBM Champion
    Posted Fri April 22, 2022 10:25 AM
    select year(CREATE_TIMESTAMP) as create_year, path_name, object_type, data_size, object_owner, CREATE_TIMESTAMP
    from table(qsys2.IFS_OBJECT_STATISTICS(
    start_path_name => '/home/ROB',
    subtree_directories => 'YES'))
    order by 1 asc
    ;

    ------------------------------
    Robert Berendt
    ------------------------------



  • 13.  RE: Archiving an IFS

    IBM Champion
    Posted Fri April 22, 2022 10:35 AM
    It wouldn't be too hard to wrap that statement into a SPL procedure, open it as a cursor and for each row returned create a command and execute it.
    MOV OBJ('/home/ROB/yaddayaddayadda') TODIR('/home/ROB/2008')

    ------------------------------
    Robert Berendt
    ------------------------------



  • 14.  RE: Archiving an IFS

    Posted Fri April 22, 2022 03:50 AM
    With no subdirectories in the backup in directory you may try this: qsh ('ls -alt /path/2/directory > /path/2/outfile/dir_list_by_last_used.out')
    This will end up with an IFS file holding the long names and change-dates.

    By adding a small 'r' as option you can sort it in the other direction.
    An 'R' will also include the subdirectories if any

    ------------------------------
    Markus Neuhold
    ------------------------------



  • 15.  RE: Archiving an IFS

    Posted Fri April 22, 2022 09:19 AM
    Wow. That is a lot of objects in one directory. (I had to look it up; for people who don't know, one "lac" or "lakh" is a hundred thousand.) For that big of a task, you almost certainly want to do the work in a Unix-style command shell (such as Bash, or at worst, Qshell) or use a scripting language such as Python. Those kinds of tools should be able to handle the volume that you have.

    ------------------------------
    John Yeung
    ------------------------------



  • 16.  RE: Archiving an IFS

    IBM Champion
    Posted Mon April 25, 2022 04:10 PM
    Try this:

    https://code.midrange.com/0b248f3ce9.html

    ------------------------------
    Robert Berendt
    ------------------------------



  • 17.  RE: Archiving an IFS

    Posted Tue April 26, 2022 02:15 AM
    @Robert Berendt Like your approach with the procedure using the SQL service and system commands!

    ------------------------------
    Markus Neuhold
    ------------------------------



  • 18.  RE: Archiving an IFS

    IBM Champion
    Posted Tue April 26, 2022 10:50 AM
    Thank you.

    ------------------------------
    Robert Berendt
    ------------------------------



  • 19.  RE: Archiving an IFS

    IBM Champion
    Posted Thu April 28, 2022 08:24 AM
    BTW, that code was copied and pasted directly from iACS Run SQL Scripts so you can paste it there and execute it.
    Change and run the SET SCHEMA
    You can skip the drop procedure unless you muck it up and want to recreate it.
    Run the CREATE PROCEDURE
    Change the final CALL at the very bottom by removing the ROB. as that's already in your SET SCHEMA at the top.  Also change the directory to yours.  Then run it.

    ------------------------------
    Robert Berendt
    ------------------------------



  • 20.  RE: Archiving an IFS

    IBM Champion
    Posted Wed April 27, 2022 04:39 PM
    In case you're not aware, 7Zip is now available as part of the Open Source Package Management RPMs. 

    It would be easy to use that from a CL program or command. Something to think about.

    ------------------------------
    Richard Schoen
    ------------------------------