Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
138 commits
Select commit Hold shift + click to select a range
2ec789d
Update Makefile.am
Abhinavpv28 Mar 10, 2026
197c173
Update configure.ac
Abhinavpv28 Mar 10, 2026
8fdce4d
Create backup_engine.c
Abhinavpv28 Mar 10, 2026
9430c34
Create backup_engine.h
Abhinavpv28 Mar 10, 2026
7de80a1
Create backup_logs.c
Abhinavpv28 Mar 10, 2026
f1bafec
Add config_load function for backup configuration
Abhinavpv28 Mar 11, 2026
021eaba
Create special_files.c
Abhinavpv28 Mar 11, 2026
282a48a
Add sys_integration.c for systemd notifications
Abhinavpv28 Mar 11, 2026
b18da6d
Create backup_logs.h
Abhinavpv28 Mar 11, 2026
ae05dbc
Create backup_types.h
Abhinavpv28 Mar 11, 2026
6f82826
Create config_manager.h
Abhinavpv28 Mar 11, 2026
e137d34
Create special_files.h
Abhinavpv28 Mar 11, 2026
7688d7b
Add sys_integration.h header file with system functions
Abhinavpv28 Mar 11, 2026
5399908
Add Makefile.am for backup_logs project
Abhinavpv28 Mar 11, 2026
eb7d83b
Create backup_utils.h
Abhinavpv28 Mar 11, 2026
11fe081
Create backup_utils.c
Abhinavpv28 Mar 11, 2026
e2d0a9e
Update backup_logs.c
Abhinavpv28 Mar 11, 2026
1324f2c
Update backup_logs.c
Abhinavpv28 Mar 11, 2026
ce2e4b0
Update backup_logs.c
Abhinavpv28 Mar 11, 2026
a929f30
Update backup_engine.c
Abhinavpv28 Mar 11, 2026
b67e3a1
Delete backup_logs/src/backup_utils.c
Abhinavpv28 Mar 12, 2026
58dd039
Delete backup_logs/include/backup_utils.h
Abhinavpv28 Mar 12, 2026
64cfae3
Update Makefile.am
Abhinavpv28 Mar 12, 2026
1db2799
Remove unused backup_utils.h include
Abhinavpv28 Mar 12, 2026
397abc1
Update config_manager.c
Abhinavpv28 Mar 12, 2026
5967554
Update config_manager.c
Abhinavpv28 Mar 12, 2026
5773630
Update config_manager.c
Abhinavpv28 Mar 12, 2026
daa1b1b
Update special_files.c
Abhinavpv28 Mar 12, 2026
92887de
Update config_manager.c
Abhinavpv28 Mar 18, 2026
1d0085d
Update backup_engine.c
Abhinavpv28 Mar 18, 2026
95c5743
Create special_files.conf
Abhinavpv28 Mar 19, 2026
f59c94c
Update backup_logs.c
Abhinavpv28 Mar 20, 2026
57ae308
Update backup_logs.c
Abhinavpv28 Mar 20, 2026
baba51a
Update sys_integration.c
Abhinavpv28 Mar 20, 2026
91a38e0
Update backup_logs.c
Abhinavpv28 Mar 20, 2026
4ba6897
Update special_files.c
Abhinavpv28 Mar 20, 2026
38faac0
Update backup_logs.h
Abhinavpv28 Mar 20, 2026
a682c06
Update backup_logs.c
Abhinavpv28 Mar 20, 2026
f65cb78
Update Makefile.am
Abhinavpv28 Mar 20, 2026
9e38575
Update backup_logs.c
Abhinavpv28 Mar 20, 2026
84bfa19
Create configure.ac
Abhinavpv28 Mar 20, 2026
4548f2d
Add Makefile.am for unit testing setup
Abhinavpv28 Mar 20, 2026
7f1fe9e
Create special_files_gtest.cpp
Abhinavpv28 Mar 20, 2026
c083bbc
Create config_manager_gtest.cpp
Abhinavpv28 Mar 20, 2026
ff0cf6b
Update Makefile.am
Abhinavpv28 Mar 20, 2026
ddf05ae
Create config_manager_mocks.h
Abhinavpv28 Mar 20, 2026
a0fa204
Create backup_logs_gtest.cpp
Abhinavpv28 Mar 20, 2026
c920ef7
Create sys_integration_gtest.cpp
Abhinavpv28 Mar 20, 2026
7914803
Update Makefile.am
Abhinavpv28 Mar 20, 2026
b26a65d
Define CPPFLAGS for config_manager_gtest
Abhinavpv28 Mar 20, 2026
e9a9122
Update Makefile.am
Abhinavpv28 Mar 20, 2026
ceffbe3
Update backup_logs.c
Abhinavpv28 Mar 20, 2026
f5290c7
Update backup_engine.h
Abhinavpv28 Mar 20, 2026
9269669
Create backup_engine_gtest.cpp
Abhinavpv28 Mar 20, 2026
a1af8b5
Add backup_engine_gtest to Makefile.am
Abhinavpv28 Mar 20, 2026
79bd4fb
Update backup_engine.c
Abhinavpv28 Mar 22, 2026
b03a9e9
Update backup_engine.c
Abhinavpv28 Mar 22, 2026
091a1ca
Update log file location to '/tmp/'
Abhinavpv28 Mar 22, 2026
c0bdb0b
Update config_manager.c
Abhinavpv28 Mar 23, 2026
d3f85bb
Update backup_engine.c
Abhinavpv28 Mar 23, 2026
e839484
Check log_path length before building destination path
Abhinavpv28 Mar 23, 2026
407aa67
Update backup_logs.c
Abhinavpv28 Mar 23, 2026
89f18a6
Apply suggestions from code review
Abhinavpv28 Mar 23, 2026
f9f5611
Apply suggestion from @Copilot
Abhinavpv28 Mar 23, 2026
f8e3aa2
Update backup_engine.c
Abhinavpv28 Mar 23, 2026
6c3031f
Update backup_engine.c
Abhinavpv28 Mar 23, 2026
c656f52
Update backup_logs/include/sys_integration.h
Abhinavpv28 Mar 23, 2026
c5eac20
Update backup_logs/include/config_manager.h
Abhinavpv28 Mar 23, 2026
096f5e0
Update backup_engine.c
Abhinavpv28 Mar 23, 2026
921a129
Update copyright year to 2026
Abhinavpv28 Mar 23, 2026
28b5e3b
Update backup_logs.c
Abhinavpv28 Mar 23, 2026
c21db55
Update config_manager.c
Abhinavpv28 Mar 23, 2026
ac6742f
Update copyright information in special_files.c
Abhinavpv28 Mar 23, 2026
e5a36f6
Update sys_integration.c
Abhinavpv28 Mar 23, 2026
7c1114c
Update backup_engine.h
Abhinavpv28 Mar 23, 2026
f802055
Update backup_logs.h
Abhinavpv28 Mar 23, 2026
799d9ac
Update backup_types.h
Abhinavpv28 Mar 23, 2026
e31c946
Update config_manager.h
Abhinavpv28 Mar 23, 2026
a51715c
Update backup_logs.h
Abhinavpv28 Mar 23, 2026
5f7fc7f
Update backup_types.h
Abhinavpv28 Mar 23, 2026
0ce3806
Update special_files.h
Abhinavpv28 Mar 23, 2026
f56af55
Update sys_integration.h
Abhinavpv28 Mar 23, 2026
a4f7df3
Update backup_engine_gtest.cpp
Abhinavpv28 Mar 23, 2026
5c8a2f2
Revise copyright and license in backup_logs_gtest.cpp
Abhinavpv28 Mar 23, 2026
4574b3a
Update config_manager_gtest.cpp
Abhinavpv28 Mar 23, 2026
a6a86f2
Update special_files_gtest.cpp
Abhinavpv28 Mar 23, 2026
64a9792
Update sys_integration_gtest.cpp
Abhinavpv28 Mar 23, 2026
fa437bf
Update copyright year and holder in Makefile.am
Abhinavpv28 Mar 23, 2026
9b5a1fc
Revise copyright and license in Makefile.am
Abhinavpv28 Mar 23, 2026
b37db99
Update configure.ac
Abhinavpv28 Mar 23, 2026
a959c7d
Revise copyright and licensing information
Abhinavpv28 Mar 23, 2026
17cbee0
Merge pull request #101 from rdkcentral/develop
Abhinavpv28 Mar 23, 2026
c9e3cdf
Delete backup_logs/unittest/backup_engine_gtest.cpp
Abhinavpv28 Mar 23, 2026
4459ced
Create backup_engine_gtest.cpp
Abhinavpv28 Mar 24, 2026
97f3df3
Update Makefile.am
Abhinavpv28 Mar 24, 2026
81404ce
Update Makefile.am
Abhinavpv28 Mar 24, 2026
4ad158f
Clean up EXTRA_DIST in Makefile.am
Abhinavpv28 Mar 24, 2026
5d82026
Update config_manager_gtest.cpp
Abhinavpv28 Mar 24, 2026
b0c455e
Update backup_logs/include/sys_integration.h
Abhinavpv28 Mar 24, 2026
84d813f
Update sys_integration.h
Abhinavpv28 Mar 24, 2026
783145e
Create test_backuplog_config_manager.py
Abhinavpv28 Mar 24, 2026
ecb7ccb
Create test_backup_engine.py
Abhinavpv28 Mar 24, 2026
8c37ae3
Create test_backuplogs_system_integration.py
Abhinavpv28 Mar 24, 2026
93ca021
Create test_backuplogs_special_files.py
Abhinavpv28 Mar 24, 2026
d9d2491
Create backup_logs_helper.py
Abhinavpv28 Mar 24, 2026
0b10093
Update backup_logs_helper.py
Abhinavpv28 Mar 24, 2026
0662184
Update copyright year to 2026 in test_backup_engine.py
Abhinavpv28 Mar 24, 2026
2fb24c1
Update copyright year in test_backuplogs_special_files.py
Abhinavpv28 Mar 24, 2026
0e6c5ea
Update copyright year in test_backuplog_config_manager.py
Abhinavpv28 Mar 24, 2026
ef46e45
Update test_backuplogs_system_integration.py
Abhinavpv28 Mar 24, 2026
0d2bdec
Create backup_logs_engine.feature
Abhinavpv28 Mar 24, 2026
0aab6e4
Create backup_logs_config_manager.feature
Abhinavpv28 Mar 24, 2026
00801fd
Create backup_logs_sys_integration.feature
Abhinavpv28 Mar 24, 2026
6a221e8
Create backup_logs_special_files.feature
Abhinavpv28 Mar 24, 2026
d2932ba
Add tools and skills for agentic development (#102)
shibu-kv Mar 24, 2026
abf95dc
Update backup_logs.h
Abhinavpv28 Mar 23, 2026
8ae2892
Update backup_types.h
Abhinavpv28 Mar 23, 2026
6c905ab
Merge branch 'develop' into feature/RDK-61009
shibu-kv Mar 24, 2026
5449814
Update backup_logs.c
Abhinavpv28 Mar 25, 2026
37b0bdf
Apply suggestion from @Copilot
Abhinavpv28 Mar 25, 2026
059e6f0
Apply suggestion from @Copilot
Abhinavpv28 Mar 25, 2026
174a65d
Apply suggestion from @Copilot
Abhinavpv28 Mar 25, 2026
6a19877
Apply suggestion from @Copilot
Abhinavpv28 Mar 25, 2026
fb4893d
Apply suggestion from @Copilot
Abhinavpv28 Mar 25, 2026
2ada0ef
Update backup_engine_gtest.cpp
Abhinavpv28 Mar 25, 2026
a112d16
Apply suggestion from @Copilot
Abhinavpv28 Mar 25, 2026
12856fb
Update backup_engine.c
Abhinavpv28 Mar 25, 2026
c1cc6f0
Update special_files.c
Abhinavpv28 Mar 25, 2026
62d6ef1
Apply suggestion from @Copilot
Abhinavpv28 Mar 25, 2026
20a025a
Apply suggestion from @Copilot
Abhinavpv28 Mar 25, 2026
59e8a1c
Update Makefile.am
Abhinavpv28 Mar 25, 2026
345ba69
Update Makefile.am
Abhinavpv28 Mar 25, 2026
cce961b
L1
Mar 25, 2026
5d53db2
Update backup_engine_gtest.cpp
Abhinavpv28 Mar 25, 2026
5e96765
L1
Mar 29, 2026
6bbf38f
Add documentation for backup_execute_common_operations
Abhinavpv28 Mar 29, 2026
6a5d533
Update config_manager.c
Abhinavpv28 Mar 29, 2026
c13f517
Update backup_engine.c
Abhinavpv28 Mar 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
##########################################################################

AUTOMAKE_OPTIONS = foreign
SUBDIRS = uploadstblogs/src usbLogUpload
SUBDIRS = uploadstblogs/src usbLogUpload backup_logs
# Install config file to /etc/backup_logs/
backup_logs_confdir = $(sysconfdir)/backup_logs
backup_logs_conf_DATA = special_files.conf

dcmd_CFLAGS += -fPIC -pthread

Expand Down
43 changes: 43 additions & 0 deletions backup_logs/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
##########################################################################
# If not stated otherwise in this file or this component's LICENSE
# file the following copyright and licenses apply:
#
# Copyright 2026 RDK Management
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
##########################################################################

AUTOMAKE_OPTIONS = foreign

# Binary program
bin_PROGRAMS = backup_logs

backup_logs_SOURCES = \
src/backup_logs.c \
src/backup_engine.c \
src/config_manager.c \
src/special_files.c \
src/sys_integration.c

backup_logs_CPPFLAGS = -I$(top_srcdir)/include \
-I$(top_srcdir)/backup_logs/include \
-I$(PKG_CONFIG_SYSROOT_DIR)/usr/include \
-DRDK_LOGGER_EXT

backup_logs_CFLAGS = -Wall -Wextra -std=c99

backup_logs_LDADD = -lm -lrdkloggers -lfwutils -lsystemd -lsecure_wrapper

backup_logs_LDFLAGS = -L$(PKG_CONFIG_SYSROOT_DIR)/usr/lib \
-L$(PKG_CONFIG_SYSROOT_DIR)/$(libdir)

81 changes: 81 additions & 0 deletions backup_logs/include/backup_engine.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2026 RDK Management
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef BACKUP_ENGINE_H
#define BACKUP_ENGINE_H

#include "backup_types.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
* @brief Execute HDD-enabled backup strategy
*
* @param config Backup configuration
* @return int BACKUP_SUCCESS on success, error code on failure
*/
int backup_execute_hdd_enabled_strategy(const backup_config_t* config);

/**
* @brief Execute HDD-disabled backup strategy with rotation
*
* @param config Backup configuration
* @return int BACKUP_SUCCESS on success, error code on failure
*/
int backup_execute_hdd_disabled_strategy(const backup_config_t* config);

/**
* @brief Execute common backup operations (special files, version files, notifications)
*
* @param config Backup configuration
* @return int BACKUP_SUCCESS on success, error code on failure
*/

int backup_execute_common_operations(const backup_config_t* config);

/**
* @brief Backup and recover logs with specified operation
*
* @param source Source path
* @param dest Destination path
* @param op Backup operation type (move, copy, delete)
* @param s_ext Source file extension filter
* @param d_ext Destination file extension
* @return int BACKUP_SUCCESS on success, error code on failure
*/
int backup_and_recover_logs(const char* source, const char* dest,
backup_operation_type_t op, const char* s_ext,
const char* d_ext);

/**
* @brief Move log files matching patterns (.txt, .log, bootlog)
*
* @param source_dir Source directory path
* @param dest_dir Destination directory path
* @return int BACKUP_SUCCESS on success, error code on failure
*/
int move_log_files_by_pattern(const char* source_dir, const char* dest_dir);

#ifdef __cplusplus
}
#endif

#endif /* BACKUP_ENGINE_H */
67 changes: 67 additions & 0 deletions backup_logs/include/backup_logs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2026 RDK Management
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef BACKUP_LOGS_H
#define BACKUP_LOGS_H

#include "backup_types.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
* @brief Main entry point for backup_logs system
*
* @param argc Command line argument count
* @param argv Command line arguments
* @return int Return code (0 for success, negative for error)
*/
int backup_logs_main(int argc, char *argv[]);

/**
* @brief Initialize backup system
*
* @param config Backup configuration structure
* @return int BACKUP_SUCCESS on success, error code on failure
*/
int backup_logs_init(backup_config_t *config);

/**
* @brief Execute complete backup process
*
* @param config Backup configuration
* @return int BACKUP_SUCCESS on success, error code on failure
*/
int backup_logs_execute(const backup_config_t *config);

/**
* @brief Cleanup and shutdown backup system
*
* @param config Backup configuration
* @return int BACKUP_SUCCESS on success, error code on failure
*/
int backup_logs_cleanup(backup_config_t *config);


#ifdef __cplusplus
}
#endif

#endif /* BACKUP_LOGS_H */
129 changes: 129 additions & 0 deletions backup_logs/include/backup_types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2026 RDK Management
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef BACKUP_TYPES_H
#define BACKUP_TYPES_H

#include <stdbool.h>
#include <limits.h>
#include <sys/param.h>

#ifdef RDK_LOGGER_EXT
#define RDK_LOGGER_ENABLED
#endif

#ifdef RDK_LOGGER_ENABLED
#include "rdk_debug.h"
#include "rdk_logger.h"
#endif

#ifdef __cplusplus
extern "C" {
#endif

/* Constants and Defines */
#define MAX_SPECIAL_FILES 32
#define MAX_ERROR_MESSAGE_LEN 256
#define MAX_FUNCTION_NAME_LEN 64
#define MAX_DESCRIPTION_LEN 128
#define MAX_CONDITIONAL_LEN 64

/* RDK Logging component name for Backup Logs */
#define LOG_BACKUP_LOGS "LOG.RDK.BACKUPLOGS"

/* Main backup configuration structure */
typedef struct {
char log_path[PATH_MAX];
char prev_log_path[PATH_MAX];
char prev_log_backup_path[PATH_MAX];
char persistent_path[PATH_MAX];
bool hdd_enabled;
} backup_config_t;

/* Backup operation types */
typedef enum {
BACKUP_OP_MOVE,
BACKUP_OP_COPY,
BACKUP_OP_DELETE
} backup_operation_type_t;

/* Special file operation types */
typedef enum {
SPECIAL_FILE_COPY = 0, // cp operation
SPECIAL_FILE_MOVE = 1 // mv operation
} special_file_operation_t;

/* Special file entry structure */
typedef struct {
char source_path[PATH_MAX];
char destination_path[PATH_MAX];
special_file_operation_t operation;
char conditional_check[MAX_CONDITIONAL_LEN]; // Optional condition variable name
} special_file_entry_t;

/* Special files configuration container */
typedef struct {
special_file_entry_t entries[MAX_SPECIAL_FILES];
size_t count;
bool config_loaded;
} special_files_config_t;

/* Backup operation structure */
typedef struct {
char source_path[PATH_MAX];
char dest_path[PATH_MAX];
backup_operation_type_t operation;
char source_extension[32];
char dest_extension[32];
} backup_operation_t;

/* Error information structure */
typedef struct {
int error_code;
char error_message[MAX_ERROR_MESSAGE_LEN];
char function_name[MAX_FUNCTION_NAME_LEN];
int line_number;
} error_info_t;

/* Return codes */
typedef enum {
BACKUP_SUCCESS = 0,
BACKUP_ERROR_CONFIG = -1,
BACKUP_ERROR_FILESYSTEM = -2,
BACKUP_ERROR_PERMISSIONS = -3,
BACKUP_ERROR_MEMORY = -4,
BACKUP_ERROR_INVALID_PARAM = -5,
BACKUP_ERROR_NOT_FOUND = -6,
BACKUP_ERROR_DISK_FULL = -7,
BACKUP_ERROR_SYSTEM = -8
} backup_result_t;

/* Configuration flags */
typedef struct {
bool debug_enabled;
bool force_rotation;
bool skip_disk_check;
bool cleanup_enabled;
} backup_flags_t;

#ifdef __cplusplus
}
#endif

#endif /* BACKUP_TYPES_H */
Loading
Loading